db

package
v0.0.0-...-69ed63b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2024 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModStatusPending  MapModStatus = "Pending"
	ModStatusAccepted MapModStatus = "Accepted"
	ModStatusDenied   MapModStatus = "Denied"
	ModStatusIgnored  MapModStatus = "Ignored"

	ModTypeIssue      MapModType = "Issue"
	ModTypeSuggestion MapModType = "Suggestion"
)
View Source
const (
	QuaverBotId int = 2
)

Variables

View Source
var (
	Redis    *redis.Client
	RedisCtx = context.Background()
)
View Source
var ElasticSearch *elasticsearch.Client
View Source
var SQL *gorm.DB

The SQL database to use throughout the application

Functions

func AddFriend

func AddFriend(userId int, targetUserId int) error

AddFriend Adds a friend to the database

func AddUserActivity

func AddUserActivity(userId int, activityType UserActivityType, value string, mapsetId int) error

AddUserActivity Adds a new user activity to the database

func CacheCountryPlayersInRedis

func CacheCountryPlayersInRedis() (map[string]string, error)

CacheCountryPlayersInRedis Caches the amount of country players in redis

func CacheJsonInRedis

func CacheJsonInRedis(key string, data interface{}, duration time.Duration, ignoreCache bool, fetch func() error) error

Helper function to cache json data in redis. The data parameter should be a pointer to the object that you're populating

func CacheTotalMapsetsInRedis

func CacheTotalMapsetsInRedis()

CacheTotalMapsetsInRedis Caches the number of total scores in redis

func CacheTotalScoresInRedis

func CacheTotalScoresInRedis()

CacheTotalScoresInRedis Caches the number of total scores in redis

func CacheTotalUsersInRedis

func CacheTotalUsersInRedis()

CacheTotalUsersInRedis Caches the number of total scores in redis

func CalculateOverallAccuracy

func CalculateOverallAccuracy(scores []*Score) float64

CalculateOverallAccuracy Calculates overall accuracy from a list of scores

func CalculateOverallRating

func CalculateOverallRating(scores []*Score) float64

CalculateOverallRating Calculates overall rating from a list of scores

func CanUserChangeUsername

func CanUserChangeUsername(userId int) (bool, time.Time, error)

CanUserChangeUsername Checks and returns if the user is allowed to change their username. When a user changes their username, they are required to wait at least 30 days before they can change it again. Returns if the user can change, the time left to change, and an error.

func ChangeUserUsername

func ChangeUserUsername(userId int, currentName string, username string) (changed bool, unchangedReason string, err error)

ChangeUserUsername Changes a user's username

func ClanLeaderboardKey

func ClanLeaderboardKey(mode enums.GameMode) string

func CloseMySQL

func CloseMySQL()

CloseMySQL Closes the MySQL database connection

func ConnectMySQL

func ConnectMySQL()

ConnectMySQL Connects to a MySQL database

func CountryLeaderboardRedisKey

func CountryLeaderboardRedisKey(country string, mode enums.GameMode) string

func CreateElasticIndex

func CreateElasticIndex(index string) error

CreateElasticIndex Creates a new elastic search index by a given name

func DeactivateRankingQueueActions

func DeactivateRankingQueueActions(mapsetId int) error

DeactivateRankingQueueActions "De-activates" ranking queue actions. This means that these specific actions do not currently count towards ranking. Example - If a mapset gets denied, all previous actions (votes/denies) no longer count

func DeleteClan

func DeleteClan(id int) error

DeleteClan Fully deletes a clan with a given id

func DeleteClanInviteById

func DeleteClanInviteById(id int) error

DeleteClanInviteById Deletes an individual clan invite

func DeleteElasticIndices

func DeleteElasticIndices(indices ...string) error

DeleteElasticIndices Deletes one or many elastic search indices

func DeleteElasticSearchMapset

func DeleteElasticSearchMapset(id int) error

DeleteElasticSearchMapset Deletes an individual mapset in elastic

func DeleteMap

func DeleteMap(id int) error

DeleteMap Deletes a map from the DB

func DeleteMapset

func DeleteMapset(id int) error

DeleteMapset Deletes (hides) a given mapset

func DeletePinnedScore

func DeletePinnedScore(userId int, scoreId int) error

DeletePinnedScore Deletes a pinned score

func DeletePlaylistMap

func DeletePlaylistMap(playlistId int, mapId int) error

DeletePlaylistMap Deletes a playlist map row

func DeletePlaylistMapset

func DeletePlaylistMapset(playlistId int, mapsetId int) error

DeletePlaylistMapset Deletes a playlist mapset row

func DeleteUserClanInvites

func DeleteUserClanInvites(userId int) error

DeleteUserClanInvites Deletes all of a user's clan invites

func DoesClanExistByName

func DoesClanExistByName(name string) (bool, error)

DoesClanExistByName Returns if a clan exists by its name

func DoesPlaylistContainMap

func DoesPlaylistContainMap(playlistId int, mapId int) (bool, error)

DoesPlaylistContainMap Checks if a playlist contains a specific map id

func GetBundledMapMd5s

func GetBundledMapMd5s() ([]string, error)

func GetCountryPlayerCountFromRedis

func GetCountryPlayerCountFromRedis(country string) (int, error)

GetCountryPlayerCountFromRedis Gets the total amount of users from a given country in redis

func GetMapsetOnlineOffsets

func GetMapsetOnlineOffsets() (interface{}, error)

GetMapsetOnlineOffsets Retrieves a list of online offsets

func GetNotificationCount

func GetNotificationCount(userId int, unreadOnly bool, category UserNotificationCategory) (int64, error)

GetNotificationCount Gets the total amount of notifications that match a given filter

func GetOnlineUserCountFromRedis

func GetOnlineUserCountFromRedis() (int, error)

GetOnlineUserCountFromRedis Retrieves the amount of online users from redis

func GetRankedMapsetIds

func GetRankedMapsetIds() ([]int, error)

GetRankedMapsetIds Retrieves a list of ranked mapset ids

func GetRankingQueueCount

func GetRankingQueueCount(mode enums.GameMode) (int, error)

GetRankingQueueCount Gets the total amount of maps in the ranking queue

func GetTotalCountryPlayersFromRedis

func GetTotalCountryPlayersFromRedis() (int, error)

GetTotalCountryPlayersFromRedis Retrieves the total amount of users on the country leaderboard

func GetTotalMapsetCountFromRedis

func GetTotalMapsetCountFromRedis() (int, error)

GetTotalMapsetCountFromRedis Retrieves the total amount of mapsets from redis

func GetTotalMultiplayerGameCount

func GetTotalMultiplayerGameCount() (int, error)

GetTotalMultiplayerGameCount Gets the total amount of multiplayer game

func GetTotalPlaylistCount

func GetTotalPlaylistCount(query string) (int, error)

GetTotalPlaylistCount Retrieves the total amount of playlists that match a given query

func GetTotalScoreCountFromRedis

func GetTotalScoreCountFromRedis() (int, error)

GetTotalScoreCountFromRedis Retrieves the total amount of scores from redis

func GetTotalUnbannedUserCount

func GetTotalUnbannedUserCount() (int, error)

GetTotalUnbannedUserCount Returns the total amount of users

func GetTotalUnreadNotifications

func GetTotalUnreadNotifications(userId int) (int64, error)

GetTotalUnreadNotifications Retrieves the total amount of unread notifications the user has

func GetTotalUserCountFromRedis

func GetTotalUserCountFromRedis() (int, error)

GetTotalUserCountFromRedis Retrieves the total amount of users from redis

func GetUserStripeSubscriptions

func GetUserStripeSubscriptions(userId int) ([]*stripe.Subscription, error)

GetUserStripeSubscriptions Gets a user's active stripe subscriptions

func GlobalLeaderboardRedisKey

func GlobalLeaderboardRedisKey(mode enums.GameMode) string

func IndexAllElasticSearchMapsets

func IndexAllElasticSearchMapsets(deletePrevious bool) error

IndexAllElasticSearchMapsets Indexes all mapsets in the DB in ElasticSearch

func IndexElasticSearchMapset

func IndexElasticSearchMapset(mapset Mapset) error

IndexElasticSearchMapset Indexes an individual mapset in elastic

func InitializeElasticSearch

func InitializeElasticSearch()

InitializeElasticSearch Initializes the ElasticSearch client

func InitializeRedis

func InitializeRedis()

InitializeRedis Initializes a Redis client

func InsertCrashLog

func InsertCrashLog(cl *CrashLog) error

InsertCrashLog Inserts a crash log into the database

func InsertMap

func InsertMap(m *MapQua) error

InsertMap Inserts a map into the database

func InsertMapsetDownload

func InsertMapsetDownload(download *MapsetDownload) error

InsertMapsetDownload Inserts a mapset download into the database

func IsUsernameAvailable

func IsUsernameAvailable(userId int, username string) (bool, error)

IsUsernameAvailable Returns if a username is available to use. - A user must not already be using that name - A user must not have used that name in the past 60 days.

func IsValidClanName

func IsValidClanName(name string) bool

IsValidClanName Checks a string to see if it is a valid clan name

func IsValidClanTag

func IsValidClanTag(tag string) bool

IsValidClanTag Checks a string to see if it is a valid clan tag

func PerformFullClanRecalculation

func PerformFullClanRecalculation(clan *Clan) error

PerformFullClanRecalculation Recalculates all of a clan's scores + stats

func RankMapset

func RankMapset(id int) error

RankMapset Ranks all maps in a mapset

func RecalculateClanStats

func RecalculateClanStats(id int, mode enums.GameMode, newScore ...*RedisScore) error

RecalculateClanStats Recalculates a clan stats for a given mode.

func RemoveClanFromLeaderboards

func RemoveClanFromLeaderboards(clanId int) error

RemoveClanFromLeaderboards Removes a clan from a given leaderboard

func RemoveFriend

func RemoveFriend(userId int, targetUserId int) error

RemoveFriend Removes a friend from the database

func RemoveUserClanScores

func RemoveUserClanScores(clanId int, userId int) error

RemoveUserClanScores Removes all user scores from a clan

func RemoveUserFromLeaderboards

func RemoveUserFromLeaderboards(user *User) error

RemoveUserFromLeaderboards Removes a user from all leaderboards

func ReplaceUserFirstPlaces

func ReplaceUserFirstPlaces(userId int) error

ReplaceUserFirstPlaces Goes through a user's first place scores and replaces it with the next unbanned player. This is used specifically when a player is banned.

func ResetPersonalBests

func ResetPersonalBests(mapset *Mapset) error

ResetPersonalBests Resets the personal best scores of all maps in a set. Usually used when ranking a mapset

func SyncPinnedScoreSortOrder

func SyncPinnedScoreSortOrder(userId int, mode enums.GameMode) error

SyncPinnedScoreSortOrder Resets the order of pinned scores to keep things in sync

func TotalHitsLeaderboardRedisKey

func TotalHitsLeaderboardRedisKey() string

func UpdateAllClanLeaderboards

func UpdateAllClanLeaderboards(clan *Clan) error

UpdateAllClanLeaderboards Updates the clan leaderboards for every mode

func UpdateClanLeaderboard

func UpdateClanLeaderboard(clan *Clan, mode enums.GameMode) error

UpdateClanLeaderboard Adds a clan to a given leaderboard

func UpdateElasticSearchMapset

func UpdateElasticSearchMapset(mapset Mapset) error

UpdateElasticSearchMapset Updates an individual mapset in elastic

func UpdateFirstPlace

func UpdateFirstPlace(md5 string, score *Score) error

func UpdateMapDifficultyRating

func UpdateMapDifficultyRating(id int, difficultyRating float64) error

UpdateMapDifficultyRating Updates the difficulty rating of a map

func UpdateMapMD5

func UpdateMapMD5(id int, md5 string) error

UpdateMapMD5 Updates the md5 hash of a map

func UpdateMapsetDescription

func UpdateMapsetDescription(id int, description string) error

UpdateMapsetDescription Updates a given mapset's description

func UpdateMapsetPackageMD5

func UpdateMapsetPackageMD5(id int, md5 string) error

UpdateMapsetPackageMD5 Updates the package md5 of a mapset

func UpdatePinnedScoreSortOrder

func UpdatePinnedScoreSortOrder(userId int, scoreId int, sortOrder int) error

UpdatePinnedScoreSortOrder Updates the sort order of a given pinned score.

func UpdatePlaylistMapCount

func UpdatePlaylistMapCount(id int, count int) error

UpdatePlaylistMapCount Updates the map count for a playlist

func UpdateUserAboutMe

func UpdateUserAboutMe(userId int, aboutMe string) error

UpdateUserAboutMe Updates a user's about me

func UpdateUserAllowed

func UpdateUserAllowed(userId int, isAllowed bool) error

UpdateUserAllowed Updates whether the user is allowed to play (banned)

func UpdateUserClan

func UpdateUserClan(userId int, clanId ...int) error

UpdateUserClan Updates a given user's clan in the database. Not passing in any clan id will set it to NULL.

func UpdateUserDiscordId

func UpdateUserDiscordId(userId int, discordId *string) error

UpdateUserDiscordId Updates a user's discord id

func UpdateUserUsername

func UpdateUserUsername(userId int, username string) error

UpdateUserUsername Updates a user's username

func UserHasBadge

func UserHasBadge(userId int, badgeId int) (bool, error)

UserHasBadge Returns if a user has a particular badge.

Types

type Achievement

type Achievement struct {
	Id           int    `gorm:"column:id; PRIMARY_KEY" json:"id"`
	Difficulty   string `gorm:"column:difficulty" json:"difficulty"`
	SteamAPIName string `gorm:"column:steam_api_name" json:"steam_api_name"`
	Name         string `gorm:"column:name" json:"name"`
	Description  string `gorm:"column:description" json:"description"`
	IsUnlocked   bool   `gorm:"-:all" json:"is_unlocked"`
}

func GetUserAchievements

func GetUserAchievements(id int) ([]*Achievement, error)

GetUserAchievements Gets a user's unlocked achievements

func (*Achievement) TableName

func (*Achievement) TableName() string

type AdminActionLog

type AdminActionLog struct {
	Id             int                `gorm:"column:id; PRIMARY_KEY"`
	AuthorId       int                `gorm:"column:author_id"`
	AuthorUsername string             `gorm:"column:author_username"`
	TargetId       int                `gorm:"column:target_id"`
	TargetUsername string             `gorm:"column:target_username"`
	Action         AdminActionLogType `gorm:"column:action"`
	Notes          string             `gorm:"column:notes"`
	Timestamp      int64              `gorm:"column:timestamp"`
}

func (*AdminActionLog) Insert

func (log *AdminActionLog) Insert() error

Insert Inserts an admin action log to the database

func (*AdminActionLog) TableName

func (*AdminActionLog) TableName() string

type AdminActionLogType

type AdminActionLogType string
const (
	AdminActionBanned  AdminActionLogType = "Banned"
	AdminActionKicked  AdminActionLogType = "Kicked"
	AdminActionUnmuted AdminActionLogType = "Unmuted"
	AdminActionUpdated AdminActionLogType = "Updated"
)

type Application

type Application struct {
	Id            int       `gorm:"column:id; PRIMARY_KEY" json:"id"`
	UserId        int       `gorm:"column:user_id" json:"user_id"`
	Name          string    `gorm:"column:name" json:"name"`
	RedirectURL   string    `gorm:"column:redirect_url" json:"redirect_url"`
	ClientId      string    `gorm:"column:client_id" json:"client_id"`
	ClientSecret  string    `gorm:"column:client_secret" json:"client_secret,omitempty"`
	Timestamp     int64     `gorm:"column:timestamp" json:"-"`
	TimestampJSON time.Time `gorm:"-:all" json:"timestamp"`
	Active        bool      `gorm:"column:active" json:"active"`
}

func GetApplicationById

func GetApplicationById(id int) (*Application, error)

GetApplicationById Retrieves an application by id

func GetUserActiveApplications

func GetUserActiveApplications(userId int) ([]*Application, error)

GetUserActiveApplications Retrieves a user's active applications

func (*Application) AfterFind

func (app *Application) AfterFind(db *gorm.DB) error

func (*Application) BeforeCreate

func (app *Application) BeforeCreate(*gorm.DB) (err error)

func (*Application) SetActiveStatus

func (app *Application) SetActiveStatus(active bool) error

SetActiveStatus Sets an applications active status

func (*Application) SetClientSecret

func (app *Application) SetClientSecret(secret string) error

SetClientSecret Sets a new secret for the application

func (*Application) SetName

func (app *Application) SetName(name string) error

SetName Sets a new name for the application

func (*Application) SetRedirectURL

func (app *Application) SetRedirectURL(url string) error

SetRedirectURL Sets a new redirect url for the application

func (*Application) TableName

func (*Application) TableName() string

type Badge

type Badge struct {
	Id          int    `gorm:"column:id; PRIMARY_KEY" json:"id"`
	Name        string `gorm:"column:name" json:"name"`
	Description string `gorm:"column:description" json:"description"`
}

func GetUserBadges

func GetUserBadges(id int) ([]*Badge, error)

GetUserBadges Retrieves a user's badges from the database

func (*Badge) TableName

func (b *Badge) TableName() string

type BoolQuery

type BoolQuery struct {
	BoolQuery struct {
		Must               []interface{} `json:"must,omitempty"`
		Should             []interface{} `json:"should,omitempty"`
		Filter             []interface{} `json:"filter,omitempty"`
		MinimumShouldMatch int           `json:"minimum_should_match,omitempty"`
	} `json:"bool,omitempty"`
}

type ChatMessage

type ChatMessage struct {
	Id            int       `gorm:"column:id; PRIMARY_KEY" json:"id"`
	SenderId      int       `gorm:"column:sender_id" json:"sender_id"`
	Type          int8      `gorm:"type" json:"type"`
	ReceiverId    *int      `gorm:"receiver_id" json:"receiver_id"`
	Channel       string    `gorm:"channel" json:"channel"`
	Message       string    `gorm:"message" json:"message"`
	Timestamp     int64     `gorm:"timestamp" json:"-"`
	TimestampJSON time.Time `gorm:"-:all" json:"timestamp"`
	IsHidden      bool      `gorm:"column:hidden" json:"-"`
	User          *User     `gorm:"foreignKey:SenderId" json:"user"`
}

func GetPrivateChatMessageHistory

func GetPrivateChatMessageHistory(userId int, otherUser int) ([]*ChatMessage, error)

GetPrivateChatMessageHistory Gets the last 50 messages of a private chat

func GetPublicChatMessageHistory

func GetPublicChatMessageHistory(channel string) ([]*ChatMessage, error)

GetPublicChatMessageHistory Gets the last 50 messages of a public chat

func (*ChatMessage) AfterFind

func (m *ChatMessage) AfterFind(*gorm.DB) (err error)

func (*ChatMessage) BeforeCreate

func (m *ChatMessage) BeforeCreate(*gorm.DB) (err error)

func (*ChatMessage) TableName

func (*ChatMessage) TableName() string

type Clan

type Clan struct {
	Id                     int          `gorm:"column:id; PRIMARY_KEY" json:"id"`
	OwnerId                int          `gorm:"column:owner_id" json:"owner_id"`
	Name                   string       `gorm:"column:name" json:"name"`
	Tag                    string       `gorm:"column:tag" json:"tag"`
	CreatedAt              int64        `gorm:"column:created_at" json:"-"`
	AboutMe                *string      `gorm:"column:about_me" json:"about_me"`
	FavoriteMode           uint8        `gorm:"column:favorite_mode" json:"favorite_mode"`
	LastNameChangeTime     int64        `gorm:"column:last_name_change_time" json:"-"`
	IsCustomizable         bool         `gorm:"column:customizable" json:"customizable"`
	CreatedAtJSON          time.Time    `gorm:"-:all" json:"created_at"`
	LastNameChangeTimeJSON time.Time    `gorm:"-:all" json:"last_name_change_time"`
	Stats                  []*ClanStats `gorm:"foreignKey:ClanId" json:"stats"`
}

func GetClanById

func GetClanById(id int) (*Clan, error)

GetClanById Gets a clan from the database by its id

func GetClanByName

func GetClanByName(name string) (*Clan, error)

GetClanByName Gets a clan from the database by its name

func GetClanLeaderboardForMode

func GetClanLeaderboardForMode(mode enums.GameMode, page int, limit int) ([]*Clan, error)

GetClanLeaderboardForMode Retrieves a clan leaderboard for a given game mode

func (*Clan) AfterFind

func (clan *Clan) AfterFind(*gorm.DB) (err error)

func (*Clan) BeforeCreate

func (clan *Clan) BeforeCreate(*gorm.DB) (err error)

func (*Clan) Insert

func (clan *Clan) Insert() error

Insert Inserts the clan into the database

func (*Clan) UpdateAboutMe

func (clan *Clan) UpdateAboutMe(aboutMe string) error

UpdateAboutMe Updates a clan's about me

func (*Clan) UpdateCustomizable

func (clan *Clan) UpdateCustomizable(enabled bool) error

UpdateCustomizable Updates a clan's customizability status

func (*Clan) UpdateFavoriteMode

func (clan *Clan) UpdateFavoriteMode(mode enums.GameMode) error

UpdateFavoriteMode Updates the favorite mode of a clan

func (*Clan) UpdateName

func (clan *Clan) UpdateName(name string) error

UpdateName Updates the name of a clan

func (*Clan) UpdateOwner

func (clan *Clan) UpdateOwner(ownerId int) error

UpdateOwner Updates the owner of a clan

func (*Clan) UpdateTag

func (clan *Clan) UpdateTag(tag string) error

UpdateTag Updates the tag of a clan

type ClanActivity

type ClanActivity struct {
	Id            int              `gorm:"column:id; PRIMARY_KEY" json:"id"`
	ClanId        int              `gorm:"column:clan_id" json:"clan_id"`
	Type          ClanActivityType `gorm:"column:type" json:"type"`
	UserId        int              `gorm:"column:user_id" json:"user_id"`
	MapId         int              `gorm:"column:map_id" json:"map_id"`
	Message       string           `gorm:"column:message" json:"message"`
	Timestamp     int64            `gorm:"column:timestamp" json:"-"`
	TimestampJSON time.Time        `gorm:"-:all" json:"timestamp"`
	User          *User            `gorm:"foreignKey:UserId" json:"user"`
}

func GetClanActivity

func GetClanActivity(clanId int, limit int, page int) ([]*ClanActivity, error)

GetClanActivity Retrieves clan activity from the database

func NewClanActivity

func NewClanActivity(clanId int, activityType ClanActivityType, userId int) *ClanActivity

NewClanActivity Creates a new clan activity

func (*ClanActivity) AfterFind

func (a *ClanActivity) AfterFind(*gorm.DB) (err error)

func (*ClanActivity) BeforeCreate

func (a *ClanActivity) BeforeCreate(*gorm.DB) (err error)

func (*ClanActivity) Insert

func (a *ClanActivity) Insert() error

Insert Inserts a clan activity into the database

func (*ClanActivity) TableName

func (*ClanActivity) TableName() string

type ClanActivityType

type ClanActivityType int8
const (
	ClanActivityNone ClanActivityType = iota
	ClanActivityCreated
	ClanActivityUserJoined
	ClanActivityUserLeft
	ClanActivityUserKicked
	ClanActivityOwnershipTransferred
)

type ClanInvite

type ClanInvite struct {
	Id            int       `gorm:"column:id; PRIMARY_KEY" json:"id"`
	ClanId        int       `gorm:"column:clan_id" json:"clan_id"`
	UserId        int       `gorm:"column:user_id" json:"user_id"`
	CreatedAt     int64     `gorm:"column:created_at" json:"-"`
	CreatedAtJSON time.Time `gorm:"-:all" json:"created_at"`
	Clan          *Clan     `gorm:"foreignKey:ClanId" json:"clan,omitempty"`
	User          *User     `gorm:"foreignKey:UserId" json:"user,omitempty"`
}

func GetClanInviteById

func GetClanInviteById(id int) (*ClanInvite, error)

GetClanInviteById GetClanInvite Retrieves a clan invite at a specific id

func GetPendingClanInvite

func GetPendingClanInvite(clanId int, userId int) (*ClanInvite, error)

GetPendingClanInvite Retrieves a clan invite for a given user

func GetPendingClanInvites

func GetPendingClanInvites(clanId int) ([]*ClanInvite, error)

GetPendingClanInvites Gets all of a clan's pending invites

func GetUserClanInvites

func GetUserClanInvites(userId int) ([]*ClanInvite, error)

GetUserClanInvites Retrieves a list of pending clan invites for the user

func InviteUserToClan

func InviteUserToClan(clanId int, userId int) (*ClanInvite, error)

InviteUserToClan Creates a clan invite for a user

func (*ClanInvite) AfterFind

func (invite *ClanInvite) AfterFind(*gorm.DB) (err error)

func (*ClanInvite) BeforeCreate

func (invite *ClanInvite) BeforeCreate(*gorm.DB) (err error)

func (*ClanInvite) TableName

func (*ClanInvite) TableName() string

type ClanScore

type ClanScore struct {
	Id              int            `gorm:"column:id; PRIMARY_KEY" json:"id"`
	ClanId          int            `gorm:"column:clan_id" json:"-"`
	MapMD5          string         `gorm:"column:map_md5" json:"-"`
	Mode            enums.GameMode `gorm:"column:mode" json:"-"`
	OverallRating   float64        `gorm:"column:overall_rating" json:"overall_rating"`
	OverallAccuracy float64        `gorm:"column:overall_accuracy" json:"overall_accuracy"`
	Timestamp       int64          `gorm:"column:timestamp" json:"-"`
	TimestampJSON   time.Time      `gorm:"-:all" json:"timestamp"`
	Map             *MapQua        `gorm:"foreignKey:MapMD5; references:MD5" json:"map,omitempty"`
	Clan            *Clan          `gorm:"foreignKey:ClanId; references:Id" json:"clan,omitempty"`
}

func CalculateClanScore

func CalculateClanScore(md5 string, clanId int, mode enums.GameMode) (*ClanScore, error)

CalculateClanScore Calculates a clan score for a given map

func GetClanScore

func GetClanScore(md5 string, clanId int) (*ClanScore, error)

GetClanScore Retrieves an existing clan score

func GetClanScoreById

func GetClanScoreById(id int) (*ClanScore, error)

GetClanScoreById Retrieves a clan score by id

func GetClanScoreboardForMap

func GetClanScoreboardForMap(md5 string) ([]*ClanScore, error)

GetClanScoreboardForMap Retrieves the clan scoreboard for a given map

func GetClanScoresForMode

func GetClanScoresForMode(clanId int, mode enums.GameMode) ([]*ClanScore, error)

GetClanScoresForMode Retrieves all clan scores for a given mode

func GetClanScoresForModeFull

func GetClanScoresForModeFull(clanId int, mode enums.GameMode, page int) ([]*ClanScore, error)

GetClanScoresForModeFull Retrieves clan scores with full data

func (*ClanScore) AfterFind

func (cs *ClanScore) AfterFind(*gorm.DB) error

func (*ClanScore) TableName

func (*ClanScore) TableName() string

func (*ClanScore) ToScore

func (cs *ClanScore) ToScore() *Score

ToScore Converts a clan score to a traditional score object, so we can reuse functions to calculate rating/acc

type ClanStats

type ClanStats struct {
	ClanId                   int            `gorm:"column:clan_id" json:"-"`
	Mode                     enums.GameMode `gorm:"column:mode" json:"mode"`
	Rank                     int            `gorm:"-:all" json:"rank"`
	OverallAccuracy          float64        `gorm:"column:overall_accuracy" json:"overall_accuracy"`
	OverallPerformanceRating float64        `gorm:"column:overall_performance_rating" json:"overall_performance_rating"`
	TotalMarv                int            `gorm:"column:total_marv" json:"total_marv"`
	TotalPerf                int            `gorm:"column:total_perf" json:"total_perf"`
	TotalGreat               int            `gorm:"column:total_great" json:"total_great"`
	TotalGood                int            `gorm:"column:total_good" json:"total_good"`
	TotalOkay                int            `gorm:"column:total_okay" json:"total_okay"`
	TotalMiss                int            `gorm:"column:total_miss" json:"total_miss"`
}

func GetClanStatsByMode

func GetClanStatsByMode(id int, mode enums.GameMode) (*ClanStats, error)

GetClanStatsByMode Retrieves clan stats by its game mode

func (*ClanStats) AfterFind

func (cs *ClanStats) AfterFind(*gorm.DB) error

func (*ClanStats) Save

func (cs *ClanStats) Save() error

func (*ClanStats) TableName

func (*ClanStats) TableName() string

type Collapse

type Collapse struct {
	Field     string    `json:"field,omitempty"`
	InnerHits InnerHits `json:"inner_hits,omitempty"`
}

type CrashLog

type CrashLog struct {
	Id        int    `gorm:"column:id; PRIMARY_KEY" json:"id"`
	UserId    int    `gorm:"column:user_id" json:"user_id"`
	Timestamp int64  `gorm:"column:timestamp"`
	Runtime   string `gorm:"column:runtime_log" json:"runtime_log"`
	Network   string `gorm:"column:network_log" json:"network_log"`
}

func (*CrashLog) TableName

func (*CrashLog) TableName() string

type ElasticHits

type ElasticHits struct {
	Hits struct {
		Hits []struct {
			InnerHits struct {
				MostRelevant struct {
					Hits struct {
						Hits []struct {
							Source ElasticMap `json:"_source"`
						} `json:"hits"`
					} `json:"hits"`
				} `json:"most_relevant"`
			} `json:"inner_hits"`
		} `json:"hits"`
	} `json:"hits"`
	Aggregations struct {
		Distinct struct {
			Total int `json:"value"`
		} `json:"distinct_mapset_ids"`
	} `json:"aggregations"`
}

type ElasticMap

type ElasticMap struct {
	*MapQua
	Explicit        bool   `json:"explicit"`
	PackageMD5      string `json:"package_md5"`
	DateSubmitted   int64  `json:"date_submitted"`
	DateLastUpdated int64  `json:"date_last_updated"`
}

type ElasticMapsetSearchOptions

type ElasticMapsetSearchOptions struct {
	Search            string               `form:"search" json:"search"`
	RankedStatus      []enums.RankedStatus `form:"ranked_status" json:"ranked_status"`
	RankedStatusArray []enums.RankedStatus `form:"ranked_status[]" json:"ranked_status[]"`
	Mode              []enums.GameMode     `form:"mode" json:"mode"`
	ModeArray         []enums.GameMode     `form:"mode[]" json:"mode[]"`
	Page              int                  `form:"page" json:"page"`
	Limit             int                  `form:"limit" json:"limit"`

	MinDifficultyRating float64 `form:"min_difficulty_rating" json:"min_difficulty_rating"`
	MaxDifficultyRating float64 `form:"max_difficulty_rating" json:"max_difficulty_rating"`
	MinBPM              float32 `form:"min_bpm" json:"min_bpm"`
	MaxBPM              float32 `form:"max_bpm" json:"max_bpm"`
	MinLength           float32 `form:"min_length" json:"min_length"`
	MaxLength           float32 `form:"max_length" json:"max_length"`
	MinLongNotePercent  float32 `form:"min_long_note_percent" json:"min_long_note_percent"`
	MaxLongNotePercent  float32 `form:"max_long_note_percent" json:"max_long_note_percent"`
	MinPlayCount        int64   `form:"min_play_count" json:"min_play_count"`
	MaxPlayCount        int64   `form:"max_play_count" json:"max_play_count"`
	MinCombo            int64   `form:"min_combo" json:"min_combo"`
	MaxCombo            int64   `form:"max_combo" json:"max_combo"`
	MinDateSubmitted    int64   `form:"min_date_submitted" json:"min_date_submitted"`
	MaxDateSubmitted    int64   `form:"max_date_submitted" json:"max_date_submitted"`
	MinLastUpdated      int64   `form:"min_last_updated" json:"min_last_updated"`
	MaxLastUpdated      int64   `form:"max_last_updated" json:"max_last_updated"`
	Explicit            bool    `form:"show_explicit" json:"show_explicit"`
}

func NewElasticMapsetSearchOptions

func NewElasticMapsetSearchOptions() *ElasticMapsetSearchOptions

func (*ElasticMapsetSearchOptions) BindAndValidate

func (options *ElasticMapsetSearchOptions) BindAndValidate()

type GameBuild

type GameBuild struct {
	Id                    int    `gorm:"column:id; PRIMARY_KEY"`
	Version               string `gorm:"column:version"`
	QuaverDll             string `gorm:"column:quaver_dll"`
	QuaverApiDll          string `gorm:"column:quaver_api_dll"`
	QuaverServerClientDll string `gorm:"column:quaver_server_client_dll"`
	QuaverServerCommonDll string `gorm:"column:quaver_server_common_dll"`
	QuaverSharedDll       string `gorm:"column:quaver_shared_dll"`
	Allowed               bool   `gorm:"column:allowed"`
	Timestamp             int64  `gorm:"column:timestamp"`
}

func (*GameBuild) Insert

func (g *GameBuild) Insert() error

Insert Inserts a new game build into the database

func (*GameBuild) TableName

func (*GameBuild) TableName() string

type InnerHits

type InnerHits struct {
	Name string      `json:"name,omitempty"`
	Size int         `json:"size,omitempty"`
	Sort interface{} `json:"sort,omitempty"`
}

type MapMod

type MapMod struct {
	Id            int              `gorm:"column:id; PRIMARY_KEY" json:"id"`
	MapId         int              `gorm:"column:map_id" json:"map_id"`
	AuthorId      int              `gorm:"column:author_id" json:"author_id"`
	Timestamp     int64            `gorm:"column:timestamp" json:"-"`
	TimestampJSON time.Time        `gorm:"-:all" json:"timestamp"`
	MapTimestamp  *string          `gorm:"column:map_timestamp" json:"map_timestamp"`
	Comment       string           `gorm:"column:comment" json:"comment"`
	Status        MapModStatus     `gorm:"column:status" json:"status"`
	Type          MapModType       `gorm:"column:type" json:"type"`
	Author        *User            `gorm:"foreignKey:AuthorId; references:Id" json:"author"`
	Replies       []*MapModComment `gorm:"foreignKey:MapModId" json:"replies"`
}

func GetMapMods

func GetMapMods(id int) ([]*MapMod, error)

GetMapMods Retrieves map mods for a given map

func GetModById

func GetModById(id int) (*MapMod, error)

GetModById Gets a mod by its id

func (*MapMod) AfterFind

func (mod *MapMod) AfterFind(*gorm.DB) (err error)

func (*MapMod) Insert

func (mod *MapMod) Insert() error

Insert Inserts a new mod into the database

func (*MapMod) TableName

func (*MapMod) TableName() string

func (*MapMod) UpdateStatus

func (mod *MapMod) UpdateStatus(status MapModStatus) error

UpdateStatus Updates the status of a map mod

type MapModComment

type MapModComment struct {
	Id            int       `gorm:"column:id; PRIMARY_KEY" json:"id"`
	MapModId      int       `gorm:"column:map_mod_id" json:"map_mod_id"`
	AuthorId      int       `gorm:"column:author_id" json:"author_id"`
	Timestamp     int64     `gorm:"column:timestamp" json:"-"`
	TimestampJSON time.Time `gorm:"-:all" json:"timestamp"`
	Comment       string    `gorm:"column:comment" json:"comments"`
	Spam          bool      `gorm:"column:spam" json:"spam"`
	Author        *User     `gorm:"foreignKey:AuthorId; references:Id" json:"author"`
}

func (*MapModComment) AfterFind

func (comment *MapModComment) AfterFind(*gorm.DB) (err error)

func (*MapModComment) Insert

func (comment *MapModComment) Insert() error

Insert Inserts a new mod comment into the database

func (*MapModComment) TableName

func (*MapModComment) TableName() string

type MapModStatus

type MapModStatus string

type MapModType

type MapModType string

type MapQua

type MapQua struct {
	Id                   int                `gorm:"column:id; PRIMARY_KEY" json:"id"`
	MapsetId             int                `gorm:"column:mapset_id" json:"mapset_id"`
	MD5                  string             `gorm:"column:md5" json:"md5"`
	AlternativeMD5       string             `gorm:"column:alternative_md5" json:"alternative_md5"`
	CreatorId            int                `gorm:"column:creator_id" json:"creator_id"`
	CreatorUsername      string             `gorm:"column:creator_username" json:"creator_username"`
	GameMode             enums.GameMode     `gorm:"column:game_mode" json:"game_mode"`
	RankedStatus         enums.RankedStatus `gorm:"column:ranked_status" json:"ranked_status"`
	Artist               string             `gorm:"column:artist" json:"artist"`
	Title                string             `gorm:"column:title" json:"title"`
	Source               string             `gorm:"column:source" json:"source"`
	Tags                 string             `gorm:"column:tags" json:"tags"`
	Description          string             `gorm:"column:description" json:"description"`
	DifficultyName       string             `gorm:"column:difficulty_name" json:"difficulty_name"`
	Length               int                `gorm:"column:length" json:"length"`
	BPM                  float32            `gorm:"column:bpm" json:"bpm"`
	DifficultyRating     float64            `gorm:"column:difficulty_rating" json:"difficulty_rating"`
	CountHitObjectNormal int                `gorm:"column:count_hitobject_normal" json:"count_hitobject_normal"`
	CountHitObjectLong   int                `gorm:"column:count_hitobject_long" json:"count_hitobject_long"`
	LongNotePercentage   float32            `gorm:"-:all" json:"long_note_percentage"`
	MaxCombo             int                `gorm:"-:all" json:"max_combo"`
	PlayCount            int                `gorm:"column:play_count" json:"play_count"`
	FailCount            int                `gorm:"column:fail_count" json:"fail_count"`
	PlayAttempts         int                `gorm:"-:all" json:"play_attempts"`
	ModsPending          int                `gorm:"column:mods_pending" json:"mods_pending"`
	ModsAccepted         int                `gorm:"column:mods_accepted" json:"mods_accepted"`
	ModsDenied           int                `gorm:"column:mods_denied" json:"mods_denied"`
	ModsIgnored          int                `gorm:"column:mods_ignored" json:"mods_ignored"`
	OnlineOffset         int                `gorm:"column:online_offset" json:"online_offset"`
	IsClanRanked         bool               `gorm:"column:clan_ranked" json:"is_clan_ranked"`
}

func GetMapById

func GetMapById(id int) (*MapQua, error)

GetMapById Retrieves a map from the database by id

func GetMapByMD5

func GetMapByMD5(md5 string) (*MapQua, error)

GetMapByMD5 Retrieves a map from the database by md5

func GetMapByMD5AndAlternative

func GetMapByMD5AndAlternative(md5 string, alternativeMd5 string) (*MapQua, error)

GetMapByMD5AndAlternative Retrieves a map from the database by either its md5 or alternative md5

func (*MapQua) AfterFind

func (m *MapQua) AfterFind(*gorm.DB) error

func (*MapQua) String

func (m *MapQua) String() string

func (*MapQua) TableName

func (m *MapQua) TableName() string

type Mapset

type Mapset struct {
	Id                  int       `gorm:"column:id; PRIMARY_KEY" json:"id"`
	PackageMD5          string    `gorm:"column:package_md5" json:"package_md5"`
	CreatorID           int       `gorm:"column:creator_id" json:"creator_id"`
	CreatorUsername     string    `gorm:"column:creator_username" json:"creator_username"`
	Artist              string    `gorm:"column:artist" json:"artist"`
	Title               string    `gorm:"column:title" json:"title"`
	Source              string    `gorm:"column:source" json:"source"`
	Tags                string    `gorm:"column:tags" json:"tags"`
	Description         string    `gorm:"column:description" json:"description"`
	DateSubmitted       int64     `gorm:"column:date_submitted" json:"-"`
	DateSubmittedJSON   time.Time `gorm:"-:all" json:"date_submitted"`
	DateLastUpdated     int64     `gorm:"column:date_last_updated" json:"-"`
	DateLastUpdatedJSON time.Time `gorm:"-:all" json:"date_last_updated"`
	IsVisible           bool      `gorm:"column:visible" json:"is_visible"`
	IsExplicit          bool      `gorm:"column:explicit" json:"is_explicit"`
	Maps                []*MapQua `gorm:"foreignKey:MapsetId" json:"maps,omitempty"`
	User                *User     `gorm:"foreignKey:CreatorID; references:Id" json:"user,omitempty"`
}

func GetAllMapsets

func GetAllMapsets() ([]*Mapset, error)

GetAllMapsets Retrieves all the mapsets in the database

func GetMapsetById

func GetMapsetById(id int) (*Mapset, error)

GetMapsetById Retrieves a mapset by its id

func GetUserMapsets

func GetUserMapsets(userId int) ([]*Mapset, error)

GetUserMapsets Retrieves a user's uploaded mapsets

func GetUserMonthlyUploadMapsets

func GetUserMonthlyUploadMapsets(userId int) ([]*Mapset, error)

GetUserMonthlyUploadMapsets Retrieves a user's mapsets that they've uploaded in the past month

func SearchElasticMapsets

func SearchElasticMapsets(options *ElasticMapsetSearchOptions) ([]*Mapset, int, error)

SearchElasticMapsets Searches ElasticSearch for mapsets

func (*Mapset) AfterFind

func (m *Mapset) AfterFind(*gorm.DB) (err error)

func (*Mapset) BeforeCreate

func (m *Mapset) BeforeCreate(*gorm.DB) (err error)

func (*Mapset) Insert

func (m *Mapset) Insert() error

func (*Mapset) String

func (m *Mapset) String() string

func (*Mapset) TableName

func (m *Mapset) TableName() string

func (*Mapset) UpdateExplicit

func (m *Mapset) UpdateExplicit(isExplicit bool) error

UpdateExplicit Sets the explicit state of the mapset

func (*Mapset) UpdateMetadata

func (m *Mapset) UpdateMetadata() error

UpdateMetadata Updates the metadata of a given mapset (username, artist, title, etc)

type MapsetDownload

type MapsetDownload struct {
	Id        int    `gorm:"column:id; PRIMARY_KEY"`
	UserId    int    `gorm:"column:user_id"`
	MapsetId  int    `gorm:"column:mapset_id"`
	Timestamp int64  `gorm:"column:timestamp"`
	Method    string `gorm:"column:method"`
}

func (*MapsetDownload) TableName

func (*MapsetDownload) TableName() string

type MapsetDownloadMethod

type MapsetDownloadMethod int8
const (
	DownloadMethodWeb MapsetDownloadMethod = iota
	DownloadMethodInGame
)

type MapsetRankingQueueComment

type MapsetRankingQueueComment struct {
	Id                  int                `gorm:"column:id; PRIMARY_KEY" json:"id"`
	UserId              int                `gorm:"column:user_id" json:"user_id"`
	MapsetId            int                `gorm:"column:mapset_id" json:"mapset_id"`
	ActionType          RankingQueueAction `gorm:"action_type" json:"action_type"`
	IsActive            bool               `gorm:"is_active" json:"is_active"` // If action counts toward ranking
	Timestamp           int64              `gorm:"column:timestamp" json:"-"`
	TimestampJSON       time.Time          `gorm:"-:all" json:"timestamp"`
	Comment             string             `gorm:"comment" json:"comment"`
	DateLastUpdated     int64              `gorm:"date_last_updated" json:"-"`
	DateLastUpdatedJSON time.Time          `gorm:"-:all" json:"date_last_updated"`
	User                *User              `gorm:"foreignKey:UserId; references:Id" json:"user,omitempty"`
}

func GetRankingQueueComment

func GetRankingQueueComment(id int) (*MapsetRankingQueueComment, error)

GetRankingQueueComment Retrieves a ranking queue comment at a given id

func GetRankingQueueComments

func GetRankingQueueComments(mapsetId int) ([]*MapsetRankingQueueComment, error)

GetRankingQueueComments Retrieves the ranking queue comments for a given mapset

func GetRankingQueueDenies

func GetRankingQueueDenies(mapsetId int) ([]*MapsetRankingQueueComment, error)

GetRankingQueueDenies Retrieves the active denies for a given mapset in the ranking queue

func GetRankingQueueVotes

func GetRankingQueueVotes(mapsetId int) ([]*MapsetRankingQueueComment, error)

GetRankingQueueVotes Retrieves the active votes for a given mapset in the ranking queue

func GetUserRankingQueueComments

func GetUserRankingQueueComments(userId int, timeStart int64, timeEnd int64) ([]*MapsetRankingQueueComment, error)

GetUserRankingQueueComments Retrieves a user's ranking queue comments between two times

func (*MapsetRankingQueueComment) AfterFind

func (c *MapsetRankingQueueComment) AfterFind(*gorm.DB) (err error)

func (*MapsetRankingQueueComment) Edit

func (c *MapsetRankingQueueComment) Edit(comment string) error

Edit Edits the content of a ranking queue comment

func (*MapsetRankingQueueComment) Insert

func (c *MapsetRankingQueueComment) Insert() error

Insert Inserts a ranking queue comment into the database

func (*MapsetRankingQueueComment) TableName

func (*MapsetRankingQueueComment) TableName() string

type MultiplayerGame

type MultiplayerGame struct {
	Id              int                       `gorm:"column:id; PRIMARY_KEY" json:"id"`
	UniqueId        string                    `gorm:"column:unique_id" json:"unique_id"`
	Name            string                    `gorm:"column:name" json:"name"`
	Type            int8                      `gorm:"column:type" json:"-"`
	TimeCreated     int64                     `gorm:"time_created" json:"-"`
	TimeCreatedJSON time.Time                 `gorm:"-:all" json:"time_created"`
	Matches         []*MultiplayerGameMatches `gorm:"foreignKey:GameId" json:"matches"`
}

func GetMultiplayerGame

func GetMultiplayerGame(id int) (*MultiplayerGame, error)

GetMultiplayerGame Gets an individual multiplayer game from the database

func GetRecentMultiplayerGames

func GetRecentMultiplayerGames(limit int, page int) ([]*MultiplayerGame, error)

GetRecentMultiplayerGames Retrieves recently played multiplayer games from the DB

func (*MultiplayerGame) AfterFind

func (mg *MultiplayerGame) AfterFind(*gorm.DB) (err error)

func (*MultiplayerGame) TableName

func (*MultiplayerGame) TableName() string

type MultiplayerGameMatches

type MultiplayerGameMatches struct {
	Id              int                      `gorm:"column:id; PRIMARY_KEY" json:"id"`
	GameId          int                      `gorm:"column:game_id" json:"game_id"`
	TimePlayed      int64                    `gorm:"column:time_played" json:"-"`
	TimePlayedJSON  time.Time                `gorm:"-:all" json:"time_played"`
	MapMD5          string                   `gorm:"column:map_md5" json:"map_md5"`
	MapString       string                   `gorm:"column:map" json:"map_string"`
	HostId          int                      `gorm:"column:host_id" json:"host_id"`
	Ruleset         int8                     `gorm:"column:ruleset" json:"-"`
	GameMode        enums.GameMode           `gorm:"column:game_mode" json:"game_mode"`
	GlobalModifiers int64                    `gorm:"column:global_modifiers" json:"global_modifiers"`
	FreeModType     int8                     `gorm:"column:free_mod_type" json:"free_mod_type"`
	HealthType      int8                     `gorm:"column:health_type" json:"-"`
	Lives           int                      `gorm:"column:lives" json:"-"`
	Aborted         bool                     `gorm:"column:aborted" json:"aborted"`
	Map             *MapQua                  `gorm:"foreignKey:MapMD5; references:MD5" json:"map"`
	Scores          []*MultiplayerMatchScore `gorm:"foreignKey:MatchId;" json:"scores,omitempty"`
}

func (*MultiplayerGameMatches) TableName

func (*MultiplayerGameMatches) TableName() string

type MultiplayerMapShare

type MultiplayerMapShare struct {
	Id         int    `gorm:"column:id; PRIMARY_KEY" json:"id"`
	UserId     int    `gorm:"column:user_id" json:"uploader_id"`
	GameId     int    `gorm:"column:game_id" json:"game_id"`
	MapMD5     string `gorm:"column:map_md5" json:"map_md5"`
	PackageMD5 string `gorm:"column:package_md5" json:"package_md5"`
	Timestamp  int64  `gorm:"timestamp" json:"timestamp"`
}

func (*MultiplayerMapShare) Insert

func (m *MultiplayerMapShare) Insert() error

func (*MultiplayerMapShare) MarshalBinary

func (m *MultiplayerMapShare) MarshalBinary() (data []byte, err error)

func (*MultiplayerMapShare) PublishToRedis

func (m *MultiplayerMapShare) PublishToRedis() error

func (*MultiplayerMapShare) TableName

func (*MultiplayerMapShare) TableName() string

func (*MultiplayerMapShare) UnmarshalBinary

func (m *MultiplayerMapShare) UnmarshalBinary(data []byte) error

type MultiplayerMatchScore

type MultiplayerMatchScore struct {
	Id                int     `gorm:"column:id; PRIMARY_KEY" json:"id"`
	UserId            int     `gorm:"column:user_id" json:"user_id"`
	MatchId           int     `gorm:"column:match_id" json:"match_id"`
	Team              int8    `gorm:"column:team" json:"-"`
	Modifiers         int64   `gorm:"column:mods" json:"modifiers"`
	PerformanceRating float64 `gorm:"column:performance_rating" json:"performance_rating"`
	Score             int     `gorm:"column:score" json:"-"`
	Accuracy          float64 `gorm:"column:accuracy" json:"accuracy"`
	MaxCombo          int     `gorm:"column:max_combo" json:"max_combo"`
	CountMarvelous    int     `gorm:"column:count_marv" json:"count_marvelous"`
	CountPerfect      int     `gorm:"column:count_perf" json:"count_perfect"`
	CountGreat        int     `gorm:"column:count_great" json:"count_great"`
	CountGood         int     `gorm:"column:count_good" json:"count_good"`
	CountOkay         int     `gorm:"column:count_okay" json:"count_okay"`
	CountMiss         int     `gorm:"column:count_miss" json:"count_miss"`
	FullCombo         bool    `gorm:"column:full_combo" json:"-"`
	LivesLeft         int     `gorm:"column:lives_left" json:"-"`
	HasFailed         bool    `gorm:"column:has_failed" json:"-"`
	Won               bool    `gorm:"column:won" json:"won"`
	BattleRoyalePlace int     `gorm:"column:battle_royale_place" json:"-"`
	User              *User   `gorm:"foreignKey:UserId; references:Id" json:"user"`
}

func (*MultiplayerMatchScore) TableName

func (*MultiplayerMatchScore) TableName() string

type Number

type Number interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | float64
}

type Order

type Order struct {
	Id             int                      `gorm:"column:id; PRIMARY_KEY" json:"id"`
	UserId         int                      `gorm:"column:user_id" json:"user_id"`
	OrderId        int                      `gorm:"column:order_id" json:"-"`
	TransactionId  string                   `gorm:"column:transaction_id" json:"-"`
	IPAddress      string                   `gorm:"column:ip_address" json:"-"`
	ItemId         OrderItemId              `gorm:"column:item_id" json:"item_id"`
	Quantity       int                      `gorm:"column:quantity" json:"quantity"`
	Amount         float32                  `gorm:"column:amount" json:"amount"`
	Description    string                   `gorm:"column:description" json:"description"`
	ReceiverUserId int                      `gorm:"column:gifted_to" json:"-"`
	Receiver       *User                    `gorm:"foreignKey:ReceiverUserId" json:"receiver"`
	Timestamp      int64                    `gorm:"column:timestamp" json:"-"`
	TimestampJSON  time.Time                `gorm:"-:all" json:"timestamp"`
	Status         OrderStatus              `gorm:"column:status" json:"status"`
	SubscriptionId *int                     `gorm:"column:subscription_id" json:"-"`
	Item           *OrderItem               `gorm:"foreignKey:ItemId" json:"item"`
	Subscription   *OrderSubscriptionStripe `gorm:"foreignKey:SubscriptionId" json:"subscription,omitempty"`
}

func GetSteamOrdersByIds

func GetSteamOrdersByIds(steamOrderId string, transactionId string) ([]*Order, error)

GetSteamOrdersByIds Retrieves orders by their steam order id & transaction id. Multiple orders in the database can have them if a user has multiple items in their cart.

func GetStripeOrderById

func GetStripeOrderById(transactionId string) ([]*Order, error)

GetStripeOrderById Gets Stripe orders by id

func GetUserOrders

func GetUserOrders(userId int) ([]*Order, error)

GetUserOrders Gets a user's orders

func (*Order) AfterFind

func (order *Order) AfterFind(*gorm.DB) (err error)

func (*Order) Finalize

func (order *Order) Finalize() error

Finalize Finalizes an order and grants the user their purchase items

func (*Order) FinalizeBadge

func (order *Order) FinalizeBadge() error

FinalizeBadge Finalizes a badge order

func (*Order) FinalizeClanCustomizable

func (order *Order) FinalizeClanCustomizable() error

FinalizeClanCustomizable Finalizes a clan customizable access order

func (*Order) FinalizeDonator

func (order *Order) FinalizeDonator() error

FinalizeDonator Finalizes a donator item

func (*Order) Insert

func (order *Order) Insert() error

Insert Inserts a new order into the database

func (*Order) SetReceiver

func (order *Order) SetReceiver(payer *User, giftUserId int) (bool, error)

SetReceiver Sets the receiver of the order. Checks if the user they are attempting to gift to exist. Returns if the receiver was successfully set and if there was a db error

func (*Order) TableName

func (*Order) TableName() string

type OrderItem

type OrderItem struct {
	Id                 int               `gorm:"column:id; PRIMARY_KEY" json:"id"`
	StripePriceId      string            `gorm:"column:stripe_price_id" json:"-"`
	Category           OrderItemCategory `gorm:"column:category" json:"category"`
	Name               string            `gorm:"column:name" json:"name"`
	PriceSteam         int               `gorm:"column:price_steam" json:"price_steam"`
	PriceStripe        int               `gorm:"column:price_stripe" json:"price_stripe"`
	MaxQuantityAllowed int               `gorm:"column:max_qty_allowed" json:"max_qty_allowed"`
	DonatorBundleItem  bool              `gorm:"column:donator_bundle_item" json:"donator_bundle_item"`
	InStock            bool              `gorm:"column:in_stock" json:"in_stock"`
	CanGift            bool              `gorm:"column:can_gift" json:"can_gift"`
	Visible            bool              `gorm:"column:visible" json:"visible"`
	BadgeId            *int              `gorm:"column:badge_id" json:"badge_id,omitempty"`
}

func GetOrderItemById

func GetOrderItemById(id int) (*OrderItem, error)

GetOrderItemById Retrieves an order item from the database by id

func (*OrderItem) TableName

func (*OrderItem) TableName() string

type OrderItemCategory

type OrderItemCategory int8
const (
	OrderItemCategoryDonator OrderItemCategory = iota
	OrderItemCategoryBadge
	OrderItemCategoryClan
)

type OrderItemId

type OrderItemId int
const (
	OrderItemDonator OrderItemId = iota + 1
	OrderItemClanCustomizable
)

type OrderStatus

type OrderStatus string
const (
	OrderStatusWaiting   OrderStatus = "Waiting"
	OrderStatusCompleted OrderStatus = "Completed"
)

type OrderSubscriptionStripe

type OrderSubscriptionStripe struct {
	Id                   int    `gorm:"column:id; PRIMARY_KEY" json:"id"`
	UserId               int    `gorm:"column:user_id" json:"user_id" json:"-"`
	StripeCustomerId     string `gorm:"column:customer_id" json:"stripe_customer_id"`
	StripeSubscriptionId string `gorm:"column:subscription_id" json:"stripe_subscription_id"`
	TimeCreated          int64  `gorm:"time_created" json:"-"`
	TimeLastUpdated      int64  `gorm:"time_last_updated" json:"-"`
	IsActive             bool   `gorm:"column:is_active" json:"-"`
}

func GetOrderSubscriptionById

func GetOrderSubscriptionById(subscriptionId string) (*OrderSubscriptionStripe, error)

GetOrderSubscriptionById Retrieves a subscription by id

func GetUserActiveSubscriptions

func GetUserActiveSubscriptions(userId int) ([]*OrderSubscriptionStripe, error)

GetUserActiveSubscriptions Retrieves a user's active stripe subscriptions

func (*OrderSubscriptionStripe) Insert

func (sub *OrderSubscriptionStripe) Insert() error

func (*OrderSubscriptionStripe) TableName

func (*OrderSubscriptionStripe) TableName() string

func (*OrderSubscriptionStripe) UpdateActiveState

func (sub *OrderSubscriptionStripe) UpdateActiveState(isActive bool) error

UpdateActiveState Sets the active state of the subscription

type PinnedScore

type PinnedScore struct {
	UserId    int            `gorm:"column:user_id" json:"user_id"`
	GameMode  enums.GameMode `gorm:"column:game_mode" json:"game_mode"`
	ScoreId   int            `gorm:"column:score_id" json:"score_id"`
	SortOrder int            `gorm:"column:sort_order" json:"sort_order"`
	Score     *Score         `gorm:"foreignKey:ScoreId; references:Id" json:"score"`
}

func GetUserPinnedScores

func GetUserPinnedScores(userId int, mode enums.GameMode) ([]*PinnedScore, error)

GetUserPinnedScores Retrieves a user's pinned scores

func (*PinnedScore) Insert

func (ps *PinnedScore) Insert() error

func (*PinnedScore) TableName

func (*PinnedScore) TableName() string

type Playlist

type Playlist struct {
	Id                  int               `gorm:"column:id; PRIMARY_KEY" json:"id"`
	UserId              int               `gorm:"column:user_id" json:"-"`
	User                *User             `gorm:"foreignKey:UserId" json:"user,omitempty"`
	Name                string            `gorm:"column:name" json:"name"`
	Description         string            `gorm:"column:description" json:"description"`
	LikeCount           int               `gorm:"column:like_count" json:"-"`
	MapCount            int               `gorm:"column:map_count" json:"map_count"`
	Timestamp           int64             `gorm:"column:timestamp" json:"-"`
	TimestampJSON       time.Time         `gorm:"-:all" json:"timestamp"`
	TimeLastUpdated     int64             `gorm:"column:time_last_updated" json:"-"`
	TimeLastUpdatedJSON time.Time         `gorm:"-:all" json:"time_last_updated"`
	Visible             bool              `gorm:"column:visible" json:"-"`
	Mapsets             []*PlaylistMapset `gorm:"foreignKey:PlaylistId" json:"mapsets,omitempty"`

	Maps []*PlaylistMap `gorm:"foreignKey:PlaylistId" json:"-"` // Only used for migration
}

func GetAllPlaylists

func GetAllPlaylists() ([]*Playlist, error)

GetAllPlaylists Returns all the playlists in the db

func GetPlaylist

func GetPlaylist(id int) (*Playlist, error)

GetPlaylist Gets an individual playlist without mapset data

func GetPlaylistFull

func GetPlaylistFull(id int) (*Playlist, error)

GetPlaylistFull Gets an individual playlist with mapsets/maps included

func GetUserPlaylists

func GetUserPlaylists(userId int) ([]*Playlist, error)

GetUserPlaylists Gets a user's created playlists

func SearchPlaylists

func SearchPlaylists(query string, limit int, page int) ([]*Playlist, error)

SearchPlaylists Returns playlists that meet a particular search query

func (*Playlist) AfterFind

func (p *Playlist) AfterFind(*gorm.DB) (err error)

func (*Playlist) BeforeSave

func (p *Playlist) BeforeSave(*gorm.DB) (err error)

func (*Playlist) Insert

func (p *Playlist) Insert() error

Insert Inserts a new playlist into the database

func (*Playlist) TableName

func (*Playlist) TableName() string

func (*Playlist) UpdateDescription

func (p *Playlist) UpdateDescription(description string) error

UpdateDescription Updates the description of a playlist

func (*Playlist) UpdateName

func (p *Playlist) UpdateName(name string) error

UpdateName Updates the name of a playlist

func (*Playlist) UpdateVisibility

func (p *Playlist) UpdateVisibility(visible bool) error

UpdateVisibility Updates the visibility of a playlist

type PlaylistMap

type PlaylistMap struct {
	Id                int     `gorm:"column:id; PRIMARY_KEY" json:"playlist_map_id"`
	PlaylistId        int     `gorm:"column:playlist_id" json:"-"`
	MapId             int     `gorm:"column:map_id" json:"-"`
	PlaylistsMapsetId int     `gorm:"column:playlists_mapsets_id" json:"-"`
	Map               *MapQua `gorm:"foreignKey:MapId" json:"map"`
}

func (*PlaylistMap) Insert

func (pm *PlaylistMap) Insert() error

Insert Inserts a playlist map into the db

func (*PlaylistMap) TableName

func (*PlaylistMap) TableName() string

func (*PlaylistMap) UpdateMapsetId

func (pm *PlaylistMap) UpdateMapsetId(playlistMapsetId int) error

UpdateMapsetId Updates the PLAYLIST mapset id for a playlist

type PlaylistMapset

type PlaylistMapset struct {
	Id         int            `gorm:"column:id; PRIMARY_KEY" json:"playlist_mapset_id"`
	PlaylistId int            `gorm:"column:playlist_id" json:"-"`
	MapsetId   int            `gorm:"column:mapset_id" json:"-"`
	Mapset     *Mapset        `gorm:"foreignKey:MapsetId" json:"mapset"`
	Maps       []*PlaylistMap `gorm:"foreignKey:PlaylistsMapsetId" json:"maps"`
}

func GetPlaylistMapsetByIds

func GetPlaylistMapsetByIds(playlistId int, mapsetId int) (*PlaylistMapset, error)

GetPlaylistMapsetByIds Gets a playlist mapset by its playlist id and mapset id

func GetPlaylistMapsetsByMapsetId

func GetPlaylistMapsetsByMapsetId(mapsetId int) ([]*PlaylistMapset, error)

GetPlaylistMapsetsByMapsetId Gets all the playlist mapsets that have a particular mapset id

func (*PlaylistMapset) Insert

func (pm *PlaylistMapset) Insert() error

Insert Inserts a playlist mapset into the db

func (*PlaylistMapset) TableName

func (*PlaylistMapset) TableName() string

type Query

type Query struct {
	From     int                    `json:"from,omitempty"`
	Size     int                    `json:"size"`
	Collapse Collapse               `json:"collapse,omitempty"`
	Query    BoolQuery              `json:"query,omitempty"`
	Sort     []map[string]SortOrder `json:"sort,omitempty"`
	Aggs     interface{}            `json:"aggs"`
}

type QueryString

type QueryString struct {
	QueryString struct {
		Query           string   `json:"query"`
		Fields          []string `json:"fields"`
		DefaultOperator string   `json:"default_operator"`
		Boost           float64  `json:"boost"`
	} `json:"query_string"`
}

func NewQueryString

func NewQueryString(query string, fields []string, defaultOperator string, boost float64) QueryString

type Range

type Range struct {
	Gte   interface{} `json:"gte,omitempty"`
	Lte   interface{} `json:"lte,omitempty"`
	Boost interface{} `json:"boost,omitempty"`
}

type RangeCustom

type RangeCustom struct {
	Range map[string]Range `json:"range,omitempty"`
}

type RankingQueueAction

type RankingQueueAction int8
const (
	RankingQueueActionComment RankingQueueAction = iota
	RankingQueueActionDeny
	RankingQueueActionBlacklist
	RankingQueueActionOnHold
	RankingQueueActionVote
	RankingQueueActionResolved
)

type RankingQueueMapset

type RankingQueueMapset struct {
	Id              int                          `gorm:"column:id; PRIMARY_KEY" json:"id"`
	MapsetId        int                          `gorm:"column:mapset_id" json:"mapset_id"`
	Timestamp       int64                        `gorm:"column:timestamp" json:"-"`
	CreatedAtJSON   time.Time                    `gorm:"-:all" json:"created_at"` // Same value as Timestamp
	DateLastUpdated int64                        `gorm:"column:date_last_updated" json:"-"`
	LastUpdatedJSON time.Time                    `gorm:"-:all" json:"last_updated"` // Same value as DateLastUpdated
	Status          RankingQueueStatus           `gorm:"column:status" json:"status"`
	NeedsAttention  bool                         `gorm:"column:needs_attention" json:"-"`
	VoteCount       int                          `gorm:"-:all" json:"-"`
	Mapset          *Mapset                      `gorm:"foreignKey:MapsetId; references:Id" json:"mapset"`
	Votes           []*MapsetRankingQueueComment `gorm:"-:all" json:"votes"`
	Denies          []*MapsetRankingQueueComment `gorm:"-:all" json:"denies"`

	Comments []*MapsetRankingQueueComment `gorm:"foreignKey:MapsetId; references:MapsetId" json:"-"`
}

func GetRankingQueue

func GetRankingQueue(mode enums.GameMode, limit int, page int) ([]*RankingQueueMapset, error)

GetRankingQueue Retrieves the ranking queue for a given game mode

func GetRankingQueueMapset

func GetRankingQueueMapset(mapsetId int) (*RankingQueueMapset, error)

GetRankingQueueMapset Retrieves a ranking queue mapset for a given mapset id

func GetUserMapsetsInRankingQueue

func GetUserMapsetsInRankingQueue(userId int) ([]*RankingQueueMapset, error)

GetUserMapsetsInRankingQueue Retrieves the mapsets the user has in the ranking queue

func (*RankingQueueMapset) AfterFind

func (mapset *RankingQueueMapset) AfterFind(*gorm.DB) (err error)

func (*RankingQueueMapset) Insert

func (mapset *RankingQueueMapset) Insert() error

Insert Inserts a mapset into the ranking queue

func (*RankingQueueMapset) TableName

func (*RankingQueueMapset) TableName() string

func (*RankingQueueMapset) UpdateStatus

func (mapset *RankingQueueMapset) UpdateStatus(status RankingQueueStatus) error

UpdateStatus Updates the status of a ranking queue mapset

func (*RankingQueueMapset) UpdateVoteCount

func (mapset *RankingQueueMapset) UpdateVoteCount(votes int) error

UpdateVoteCount Updates the vote count of a ranking queue mapset

type RankingQueueStatus

type RankingQueueStatus int8
const (
	RankingQueuePending RankingQueueStatus = iota
	RankingQueueDenied
	RankingQueueBlacklisted
	RankingQueueOnHold
	RankingQueueResolved
	RankingQueueRanked
)

type RedisScore

type RedisScore struct {
	Map struct {
		Id                   int                `json:"id"`
		MD5                  string             `json:"md5"`
		GameMode             enums.GameMode     `json:"game_mode"`
		RankedStatus         enums.RankedStatus `json:"ranked_status"`
		DifficultyRating     float64            `json:"difficulty_rating"`
		ClanRanked           bool               `json:"clan_ranked"`
		CountHitobjectNormal int                `json:"count_hitobject_normal"`
		CountHitobjectLong   int                `json:"count_hitobject_long"`
	} `json:"map"`
	Score struct {
		Id                int     `json:"id"`
		PerformanceRating float64 `json:"performance_rating"`
		PersonalBest      bool    `json:"personal_best"`
		Failed            bool    `json:"failed"`
		Accuracy          float64 `json:"accuracy"`
		CountMarvelous    int     `json:"count_marvelous"`
		CountPerfect      int     `json:"count_perfect"`
		CountGreat        int     `json:"count_great"`
		CountGood         int     `json:"count_good"`
		CountOkay         int     `json:"count_okay"`
		CountMiss         int     `json:"count_miss"`
	} `json:"score"`
	User struct {
		Id           int    `json:"id"`
		Username     string `json:"username"`
		Country      string `json:"country"`
		ShadowBanned bool   `json:"shadow_banned"`
		ClanId       int    `json:"clan_id"`
	} `json:"user"`
}

type Score

type Score struct {
	Id                          int              `gorm:"column:id; PRIMARY_KEY" json:"id"`
	UserId                      int              `gorm:"column:user_id" json:"user_id"`
	MapMD5                      string           `gorm:"column:map_md5" json:"map_md5"`
	ReplayMD5                   string           `gorm:"column:replay_md5" json:"replay_md5"`
	Mode                        enums.GameMode   `gorm:"column:mode" json:"mode"`
	Timestamp                   int64            `gorm:"column:timestamp" json:"-"`
	TimestampJSON               time.Time        `gorm:"-:all" json:"timestamp"`
	IsPersonalBest              bool             `gorm:"column:personal_best" json:"is_personal_best"`
	PerformanceRating           float64          `gorm:"column:performance_rating" json:"performance_rating"`
	Modifiers                   int64            `gorm:"column:mods" json:"modifiers"`
	Failed                      bool             `gorm:"column:failed" json:"failed"`
	TotalScore                  int              `gorm:"column:total_score" json:"total_score"`
	Accuracy                    float64          `gorm:"column:accuracy" json:"accuracy"`
	MaxCombo                    int              `gorm:"column:max_combo" json:"max_combo"`
	CountMarvelous              int              `gorm:"column:count_marv" json:"count_marvelous"`
	CountPerfect                int              `gorm:"column:count_perf" json:"count_perfect"`
	CountGreat                  int              `gorm:"column:count_great" json:"count_great"`
	CountGood                   int              `gorm:"column:count_good" json:"count_good"`
	CountOkay                   int              `gorm:"column:count_okay" json:"count_okay"`
	CountMiss                   int              `gorm:"column:count_miss" json:"count_miss"`
	Grade                       string           `gorm:"column:grade" json:"grade"`
	ScrollSpeed                 int              `gorm:"column:scroll_speed" json:"scroll_speed"`
	TimePlayStart               int64            `gorm:"column:time_play_start" json:"-"`
	TimePlayEnd                 int64            `gorm:"column:time_play_end" json:"-"`
	IP                          string           `gorm:"column:ip" json:"-"`
	ExecutingAssembly           string           `gorm:"column:executing_assembly" json:"-"`
	EntryAssembly               string           `gorm:"column:entry_assembly" json:"-"`
	QuaverVersion               string           `gorm:"column:quaver_version" json:"-"`
	PauseCount                  int              `gorm:"column:pause_count" json:"-"`
	PerformanceProcessorVersion string           `gorm:"column:performance_processor_version" json:"-"`
	DifficultyProcessorVersion  string           `gorm:"column:difficulty_processor_version" json:"-"`
	IsDonatorScore              bool             `gorm:"column:is_donator_score" json:"is_donator_score"`
	TournamentGameId            *int             `gorm:"column:tournament_game_id" json:"tournament_game_id"`
	ClanId                      *int             `gorm:"column:clan_id" json:"clan_id"`
	Map                         *MapQua          `gorm:"foreignKey:MapMD5; references:MD5" json:"map,omitempty"`
	User                        *User            `gorm:"foreignKey:UserId; references:Id" json:"user,omitempty"`
	FirstPlace                  *ScoreFirstPlace `gorm:"foreignKey:Id; references:ScoreId" json:"-"`
}

func GetAllScoresForMap

func GetAllScoresForMap(md5 string) ([]*Score, error)

GetAllScoresForMap Retrieves all scores for a map

func GetClanPlayerScoresOnMap

func GetClanPlayerScoresOnMap(md5 string, clanId int, callAfterFind bool) ([]*Score, error)

GetClanPlayerScoresOnMap Fetches the top 10 scores from a clan on a given map

func GetCountryScoresForMap

func GetCountryScoresForMap(md5 string, country string) ([]*Score, error)

GetCountryScoresForMap Retrieves the country scores for a map

func GetFriendScoresForMap

func GetFriendScoresForMap(md5 string, userId int, friends []*UserFriend, limit int, page int) ([]*Score, error)

GetFriendScoresForMap Retrieves the friend scores for a map

func GetGlobalScoresForMap

func GetGlobalScoresForMap(md5 string, useCache bool) ([]*Score, error)

GetGlobalScoresForMap Retrieves the global scores for a map

func GetModifierScoresForMap

func GetModifierScoresForMap(md5 string, mods int64) ([]*Score, error)

GetModifierScoresForMap Retrieves the modifier scores for a map

func GetRateScoresForMap

func GetRateScoresForMap(md5 string, mods int64) ([]*Score, error)

GetRateScoresForMap Retrieves the rate scores for a map

func GetScoreById

func GetScoreById(id int) (*Score, error)

GetScoreById Retrieves a score from the database by its id

func GetUserBestScoresForMode

func GetUserBestScoresForMode(id int, mode enums.GameMode, limit int, page int) ([]*Score, error)

GetUserBestScoresForMode Retrieves a user's best scores for a given game mode

func GetUserFirstPlaceScoresForMode

func GetUserFirstPlaceScoresForMode(id int, mode enums.GameMode, limit int, page int) ([]*Score, error)

GetUserFirstPlaceScoresForMode Retrieves a user's first place scores for a given mode

func GetUserGradeScoresForMode

func GetUserGradeScoresForMode(id int, mode enums.GameMode, grade string, limit int, page int) ([]*Score, error)

GetUserGradeScoresForMode Retrieves a user's scores for a particular grade

func GetUserPersonalBestScoreAll

func GetUserPersonalBestScoreAll(userId int, md5 string) (*Score, error)

GetUserPersonalBestScoreAll Retrieves a user's personal best ALL score on a given map

func GetUserPersonalBestScoreGlobal

func GetUserPersonalBestScoreGlobal(userId int, md5 string) (*Score, error)

GetUserPersonalBestScoreGlobal Retrieves a user's personal best global score on a given map

func GetUserPersonalBestScoreMods

func GetUserPersonalBestScoreMods(userId int, md5 string, mods int64) (*Score, error)

GetUserPersonalBestScoreMods Retrieves a user's personal best modifier score on a given map

func GetUserPersonalBestScoreRate

func GetUserPersonalBestScoreRate(userId int, md5 string, mods int64) (*Score, error)

GetUserPersonalBestScoreRate Retrieves a user's personal best rate score on a given map

func GetUserRecentScoresForMode

func GetUserRecentScoresForMode(id int, mode enums.GameMode, isDonator bool, limit int, page int) ([]*Score, error)

GetUserRecentScoresForMode Retrieves a user's recent scores for a given mode

func (*Score) AfterFind

func (s *Score) AfterFind(*gorm.DB) (err error)

func (*Score) BeforeCreate

func (s *Score) BeforeCreate(*gorm.DB) (err error)

func (*Score) TableName

func (s *Score) TableName() string

type ScoreFirstPlace

type ScoreFirstPlace struct {
	MD5               string  `gorm:"column:md5" json:"md5"`
	UserId            int     `gorm:"column:user_id" json:"user_id"`
	ScoreId           int     `gorm:"column:score_id" json:"score_id"`
	PerformanceRating float64 `gorm:"column:performance_rating" json:"performance_rating"`
}

func GetUserFirstPlaces

func GetUserFirstPlaces(userId int) ([]*ScoreFirstPlace, error)

GetUserFirstPlaces Retrieves all of a user's first place scores

func (*ScoreFirstPlace) TableName

func (s *ScoreFirstPlace) TableName() string

type SortOrder

type SortOrder struct {
	Order string `json:"order"`
}

type Team

type Team struct {
	Developers         []*User `json:"developers"`
	Administrators     []*User `json:"administrators"`
	Moderators         []*User `json:"moderators"`
	RankingSupervisors []*User `json:"ranking_supervisors"`
	Contributors       []*User `json:"contributors"`
}

func GetTeamMembers

func GetTeamMembers() (*Team, error)

GetTeamMembers Returns users in the Quaver team

type Term

type Term struct {
	Value interface{} `json:"value"`
	Boost float64     `json:"boost"`
}

type TermCustom

type TermCustom struct {
	Term struct {
		GameMode     *Term `json:"game_mode,omitempty"`
		RankedStatus *Term `json:"ranked_status,omitempty"`
		Explicit     *Term `json:"explicit,omitempty"`
	} `json:"term"`
}

type User

type User struct {
	Id                          int               `gorm:"column:id; PRIMARY_KEY" json:"id"`
	SteamId                     string            `gorm:"column:steam_id" json:"steam_id"`
	Username                    string            `gorm:"column:username" json:"username"`
	TimeRegistered              int64             `gorm:"column:time_registered" json:"-"`
	TimeRegisteredJSON          time.Time         `gorm:"-:all" json:"time_registered"`
	Allowed                     bool              `gorm:"column:allowed" json:"allowed"`
	Privileges                  enums.Privileges  `gorm:"column:privileges" json:"privileges"`
	UserGroups                  enums.UserGroups  `gorm:"column:usergroups" json:"usergroups"`
	MuteEndTime                 int64             `gorm:"column:mute_endtime" json:"-"`
	MuteEndTimeJSON             time.Time         `gorm:"-:all" json:"mute_end_time"`
	LatestActivity              int64             `gorm:"column:latest_activity" json:"-"`
	LatestActivityJSON          time.Time         `gorm:"-:all" json:"latest_activity"`
	Country                     string            `gorm:"column:country" json:"country"`
	IP                          string            `gorm:"column:ip" json:"-"`
	AvatarUrl                   *string           `gorm:"column:avatar_url" json:"avatar_url"`
	Twitter                     *string           `gorm:"column:twitter" json:"twitter"`
	Title                       *string           `gorm:"column:title" json:"title"`
	CheckedPreviousAchievements bool              `gorm:"column:checked_previous_achievements" json:"-"`
	UserPage                    *string           `gorm:"column:userpage" json:"userpage"`
	TwitchUsername              *string           `gorm:"column:twitch_username" json:"twitch_username"`
	DonatorEndTime              int64             `gorm:"column:donator_end_time" json:"-"`
	DonatorEndTimeJSON          time.Time         `gorm:"-:all" json:"donator_end_time"`
	Notes                       *string           `gorm:"column:notes" json:"-"`
	DiscordId                   *string           `gorm:"column:discord_id" json:"discord_id"`
	Information                 *string           `gorm:"column:information" json:"-"`
	MiscInformation             *UserInformation  `gorm:"-:all" json:"misc_information"`
	UserPageDisabled            bool              `gorm:"column:userpage_disabled" json:"-"`
	ClanId                      *int              `gorm:"column:clan_id" json:"clan_id"`
	ClanLeaveTime               int64             `gorm:"column:clan_leave_time" json:"-"`
	ClanLeaveTimeJSON           time.Time         `gorm:"-:all" json:"clan_leave_time"`
	ShadowBanned                bool              `gorm:"column:shadow_banned" json:"-"`
	RememberToken               *string           `gorm:"column:remember_token" json:"-"`
	ClientStatus                *UserClientStatus `gorm:"-:all" json:"client_status"`
	StatsKeys4                  *UserStatsKeys4   `gorm:"foreignKey:UserId" json:"stats_keys4,omitempty"`
	StatsKeys7                  *UserStatsKeys7   `gorm:"foreignKey:UserId" json:"stats_keys7,omitempty"`
}

func GetCountryLeaderboard

func GetCountryLeaderboard(country string, mode enums.GameMode, page int, limit int) ([]*User, error)

GetCountryLeaderboard Retrieves the country leaderboard for a given country and mode

func GetGlobalLeaderboard

func GetGlobalLeaderboard(mode enums.GameMode, page int, limit int) ([]*User, error)

GetGlobalLeaderboard Retrieves the global leaderboard for a specific game mode

func GetRankingSupervisors

func GetRankingSupervisors(ignoreCache bool) ([]*User, error)

GetRankingSupervisors Returns users who are Ranking Supervisors

func GetTotalHitsLeaderboard

func GetTotalHitsLeaderboard(page int, limit int) ([]*User, error)

GetTotalHitsLeaderboard Retrieves the total hits leaderboard for a specific game mode

func GetUserById

func GetUserById(id int) (*User, error)

GetUserById Retrieves a user from the database by their user id

func GetUserBySteamId

func GetUserBySteamId(id string) (*User, error)

GetUserBySteamId Retrieves a user from the database by their steam id

func GetUserByUsername

func GetUserByUsername(username string) (*User, error)

GetUserByUsername Retrieves a user from the database by their username

func GetUsersInClan

func GetUsersInClan(clanId int) ([]*User, error)

GetUsersInClan Retrieves all the users that are in a given clan

func SearchUsersByName

func SearchUsersByName(searchQuery string) ([]*User, error)

SearchUsersByName Searches for users that have a similar name to the query

func (*User) AfterFind

func (u *User) AfterFind(*gorm.DB) (err error)

func (*User) BeforeCreate

func (u *User) BeforeCreate(*gorm.DB) (err error)

func (*User) CanJoinClan

func (u *User) CanJoinClan() bool

CanJoinClan Returns if the user is eligible to join a new clan

func (*User) Insert

func (u *User) Insert() error

Insert Inserts a new user to the database

func (*User) IsTrialRankingSupervisor

func (u *User) IsTrialRankingSupervisor() bool

IsTrialRankingSupervisor Returns if the user is a trial ranking supervisor

func (*User) UpdateDonatorEndTime

func (u *User) UpdateDonatorEndTime(endTime int64) error

UpdateDonatorEndTime UpdateUserGroups Sets & updates a user's donator end time

func (*User) UpdateUserGroups

func (u *User) UpdateUserGroups(groups enums.UserGroups) error

UpdateUserGroups Sets & updates a user's usergroups

type UserAchievement

type UserAchievement struct {
	UserId        int `gorm:"column:user_id" json:"user_id"`
	AchievementId int `gorm:"column_achievement_id" json:"achievement_id"`
}

func (*UserAchievement) TableName

func (*UserAchievement) TableName() string

type UserActivity

type UserActivity struct {
	Id            int              `gorm:"column:id; PRIMARY_KEY" json:"id"`
	UserId        int              `gorm:"column:user_id" json:"user_id"`
	Type          UserActivityType `gorm:"column:type" json:"type"`
	Timestamp     int64            `gorm:"column:timestamp" json:"-"`
	TimestampJSON time.Time        `gorm:"-:all" json:"timestamp"`
	Value         string           `gorm:"column:value" json:"value"`
	MapsetId      int              `gorm:"mapset_id" json:"mapset_id"`
}

func GetRecentUserActivity

func GetRecentUserActivity(id int, limit int, page int) ([]*UserActivity, error)

GetRecentUserActivity Gets the most recent user activity

func (*UserActivity) AfterFind

func (ua *UserActivity) AfterFind(*gorm.DB) (err error)

func (*UserActivity) BeforeCreate

func (ua *UserActivity) BeforeCreate(*gorm.DB) (err error)

func (*UserActivity) Insert

func (ua *UserActivity) Insert() error

Insert Inserts a new user activity to the database directly with the object

func (*UserActivity) TableName

func (*UserActivity) TableName() string

type UserActivityType

type UserActivityType int
const (
	UserActivityRegistered UserActivityType = iota
	UserActivityUploadedMapset
	UserActivityUpdatedMapset
	UserActivityRankedMapset
	UserActivityDeniedMapset
	UserActivityAchievedFirstPlace
	UserActivityLostFirstPlace
	UserActivityUnlockedAchievement
	UserActivityDonated
	UserActivityReceivedDonatorGift
)

type UserBadge

type UserBadge struct {
	UserId  int `gorm:"column:user_id" json:"user_id"`
	BadgeId int `gorm:"column:badge_id" json:"badge_id"`
}

func (*UserBadge) Insert

func (ub *UserBadge) Insert() error

func (*UserBadge) TableName

func (ub *UserBadge) TableName() string

type UserClientStatus

type UserClientStatus struct {
	Status  int    `json:"status"`
	Mode    int    `json:"mode"`
	Content string `json:"content"`
}

func GetUserClientStatus

func GetUserClientStatus(id int) (*UserClientStatus, error)

GetUserClientStatus Retrieves a user's client status from Redis

type UserFriend

type UserFriend struct {
	User
	IsMutual bool `json:"is_mutual"`
}

func GetUserFriends

func GetUserFriends(userId int) ([]*UserFriend, error)

GetUserFriends Returns a user's friends list

type UserInformation

type UserInformation struct {
	Discord             string         `json:"discord,omitempty"`
	Twitter             string         `json:"twitter,omitempty"`
	Twitch              string         `json:"twitch,omitempty"`
	Youtube             string         `json:"youtube,omitempty"`
	NotifyMapsetActions bool           `json:"notif_action_mapset,omitempty"`
	DefaultMode         enums.GameMode `json:"default_mode,omitempty"`
}

type UserMostPlayedMap

type UserMostPlayedMap struct {
	Id              int    `gorm:"column:id" json:"id"`
	CreatorId       int    `gorm:"column:creator_id" json:"creator_id"`
	CreatorUsername string `gorm:"column:creator_username" json:"creator_username"`
	Artist          string `gorm:"column:artist" json:"artist"`
	Title           string `gorm:"column:title" json:"title"`
	DifficultyName  string `gorm:"column:difficulty_name" json:"difficulty_name"`
	Count           int    `gorm:"column:COUNT(*)" json:"count"`
}

func GetUserMostPlayedMaps

func GetUserMostPlayedMaps(id int, limit int, page int) ([]*UserMostPlayedMap, error)

GetUserMostPlayedMaps Returns a user's most played maps

type UserNotification

type UserNotification struct {
	Id            int                      `gorm:"column:id; PRIMARY KEY" json:"id"`
	SenderId      int                      `gorm:"column:sender_id" json:"sender_id"`
	ReceiverId    int                      `gorm:"column:receiver_id" json:"receiver_id"`
	Type          UserNotificationType     `gorm:"column:type" json:"type"`
	Category      UserNotificationCategory `gorm:"column:category" json:"category"`
	RawData       string                   `gorm:"column:data" json:"-"`
	Data          json.RawMessage          `gorm:"-:all" json:"data"`
	ReadAt        int64                    `gorm:"column:read_at" json:"-"`
	ReadAtJSON    time.Time                `gorm:"-:all" json:"read_at"`
	Timestamp     int64                    `gorm:"column:timestamp" json:"-"`
	TimestampJSON time.Time                `gorm:"-:all" json:"timestamp"`
	User          *User                    `gorm:"foreignKey:SenderId; references:Id" json:"user"`
}

func GetNotificationById

func GetNotificationById(id int) (*UserNotification, error)

GetNotificationById Retrieves a user notification by id

func GetNotifications

func GetNotifications(userId int, unreadOnly bool, page int, limit int, category UserNotificationCategory) ([]*UserNotification, error)

GetNotifications Retrieves a user's notifications

func NewClanInviteNotification

func NewClanInviteNotification(clan *Clan, invite *ClanInvite) *UserNotification

NewClanInviteNotification Returns a new clan invite notification

func NewClanKickedNotification

func NewClanKickedNotification(clan *Clan, userId int) *UserNotification

NewClanKickedNotification Returns a new clan kicked notification

func NewDonatorExpiredNotification

func NewDonatorExpiredNotification(userId int) *UserNotification

NewDonatorExpiredNotification Returns a new donator expired notification

func NewMapModCommentNotification

func NewMapModCommentNotification(mapQua *MapQua, mod *MapMod, comment *MapModComment) *UserNotification

NewMapModCommentNotification Returns a new map mod comment notification

func NewMapModNotification

func NewMapModNotification(mapQua *MapQua, mod *MapMod) *UserNotification

NewMapModNotification Returns a new map mod notification

func NewMapsetActionNotification

func NewMapsetActionNotification(mapset *Mapset, comment *MapsetRankingQueueComment) *UserNotification

Returns a new mapset ranking queue action notification

func NewMapsetRankedNotification

func NewMapsetRankedNotification(mapset *Mapset) *UserNotification

NewMapsetRankedNotification Returns a new ranked mapset notification

func NewOrderItemGiftNotification

func NewOrderItemGiftNotification(order *Order) *UserNotification

NewOrderItemGiftNotification Returns a new order gift notification

func (*UserNotification) AfterFind

func (n *UserNotification) AfterFind(*gorm.DB) error

func (*UserNotification) Insert

func (n *UserNotification) Insert() error

func (*UserNotification) TableName

func (*UserNotification) TableName() string

func (*UserNotification) UpdateReadStatus

func (n *UserNotification) UpdateReadStatus(isRead bool) error

UpdateReadStatus Updates the read status of a notification

type UserNotificationCategory

type UserNotificationCategory int
const (
	NotificationCategoryProfile UserNotificationCategory = iota + 1
	NotificationCategoryClan
	NotificationCategoryRankingQueue
	NotificationCategoryMapModding
)

type UserNotificationType

type UserNotificationType int
const (
	NotificationMapsetRanked UserNotificationType = iota + 1
	NotificationMapsetAction
	NotificationMapMod
	NotificationMapModComment
	NotificationClanInvite
	NotificationMuted
	NotificationReceivedOrderItemGift
	NotificationDonatorExpired
	NotificationClanKicked
)

type UserRank

type UserRank struct {
	UserId                   int       `gorm:"column:user_id" json:"-"`
	Rank                     int       `gorm:"column:rank" json:"rank"`
	OverallPerformanceRating float64   `gorm:"column:overall_performance_rating" json:"overall_performance_rating"`
	Timestamp                time.Time `gorm:"type:date; column:timestamp" json:"timestamp"`
}

func GetUserRankStatisticsForMode

func GetUserRankStatisticsForMode(id int, mode enums.GameMode) ([]*UserRank, error)

GetUserRankStatisticsForMode Retrieves a users rank statistics for a given game mode

type UserRankKeys4

type UserRankKeys4 UserRank

func (*UserRankKeys4) TableName

func (ur *UserRankKeys4) TableName() string

type UserRankKeys7

type UserRankKeys7 UserRank

func (*UserRankKeys7) TableName

func (ur *UserRankKeys7) TableName() string

type UserRanks

type UserRanks struct {
	Global    int `json:"global"`
	Country   int `json:"country"`
	TotalHits int `json:"total_hits"`
}

func GetUserRanksForMode

func GetUserRanksForMode(user *User, mode enums.GameMode) (*UserRanks, error)

GetUserRanksForMode Retrieves a user's global and country ranks for a game mode

type UserRelationship

type UserRelationship struct {
	Id           int   `gorm:"column:id" json:"-"`
	UserId       int   `gorm:"column:user_id" json:"-"`
	TargetUserId int   `gorm:"column:target_user_id" json:"-"`
	Relationship int8  `gorm:"column:relationship" json:"-"`
	User         *User `gorm:"foreignKey:TargetUserId" json:"-"`
}

func GetUserRelationship

func GetUserRelationship(userId int, targetUserId int) (*UserRelationship, error)

GetUserRelationship Retrieves a user relationship in the database

func (*UserRelationship) TableName

func (*UserRelationship) TableName() string

type UserStats

type UserStats struct {
	UserId                   int        `gorm:"column:user_id" json:"-"`
	Ranks                    *UserRanks `gorm:"-:all" json:"ranks"`
	TotalScore               int64      `gorm:"column:total_score" json:"total_score"`
	RankedScore              int64      `gorm:"column:ranked_score" json:"ranked_score"`
	OverallAccuracy          float64    `gorm:"column:overall_accuracy" json:"overall_accuracy"`
	OverallPerformanceRating float64    `gorm:"column:overall_performance_rating" json:"overall_performance_rating"`
	PlayCount                int        `gorm:"column:play_count" json:"play_count"`
	FailCount                int        `gorm:"column:fail_count" json:"fail_count"`
	MaxCombo                 int        `gorm:"column:max_combo" json:"max_combo"`
	TotalMarvelous           int        `gorm:"column:total_marv" json:"total_marvelous"`
	TotalPerfect             int        `gorm:"column:total_perf" json:"total_perfect"`
	TotalGreat               int        `gorm:"column:total_great" json:"total_great"`
	TotalGood                int        `gorm:"column:total_good" json:"total_good"`
	TotalOkay                int        `gorm:"column:total_okay" json:"total_okay"`
	TotalMiss                int        `gorm:"column:total_miss" json:"total_miss"`
	CountGradeX              int        `gorm:"column:count_grade_x" json:"count_grade_x"`
	CountGradeSS             int        `gorm:"column:count_grade_ss" json:"count_grade_ss"`
	CountGradeS              int        `gorm:"column:count_grade_s" json:"count_grade_s"`
	CountGradeA              int        `gorm:"column:count_grade_a" json:"count_grade_a"`
	CountGradeB              int        `gorm:"column:count_grade_b" json:"count_grade_b"`
	CountGradeC              int        `gorm:"column:count_grade_c" json:"count_grade_c"`
	CountGradeD              int        `gorm:"column:count_grade_d" json:"count_grade_d"`
}

type UserStatsKeys4

type UserStatsKeys4 UserStats

func (*UserStatsKeys4) TableName

func (*UserStatsKeys4) TableName() string

type UserStatsKeys7

type UserStatsKeys7 UserStats

func (*UserStatsKeys7) TableName

func (*UserStatsKeys7) TableName() string

type UsernameChange

type UsernameChange struct {
	Id               int    `gorm:"column:id; PRIMARY_KEY"`
	UserId           int    `gorm:"column:user_Id"`
	PreviousUsername string `gorm:"previous_username"`
	Timestamp        int64  `gorm:"timestamp"`
}

func (*UsernameChange) TableName

func (*UsernameChange) TableName() string

type WeeklyMostPlayedMapsets

type WeeklyMostPlayedMapsets struct {
	MapsetId        int    `gorm:"column:mapset_id" json:"id"`
	CreatorId       int    `gorm:"column:creator_id" json:"creator_id"`
	CreatorUsername string `gorm:"column:creator_username" json:"creator_username"`
	Artist          string `gorm:"column:artist" json:"artist"`
	Title           string `gorm:"column:title" json:"title"`
	Count           int    `gorm:"column:COUNT(*)" json:"count"`
}

func GetWeeklyMostPlayedMapsets

func GetWeeklyMostPlayedMapsets(ignoreCache bool) ([]*WeeklyMostPlayedMapsets, error)

GetWeeklyMostPlayedMapsets Retrieves the most played mapsets in the past week

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL