Documentation ¶
Index ¶
- Variables
- func CalculateClanOverallAccuracy(clan int, mode int) (float64, error)
- func CalculateClanOverallRating(clan int, mode int) (float64, error)
- func CalculateOverallAccuracy(scores []Score) float64
- func CalculateOverallRating(scores []Score) float64
- func CloseSQLConnection()
- func GetCountryLeaderboardKey(u *User, mode common.Mode) string
- func GetGlobalLeaderboardKey(mode common.Mode) string
- func IncrementMapPlayCount(id int, failed bool) error
- func InitializeRedis()
- func InitializeSQL()
- func InsertActivityFeed(userId int, feed ActivityFeed, value string, mapsetId int) error
- func InsertClanScore(score *ClanScore) error
- func PublishFirstPlaceScoreRedis(username, artist, title, difficultyName string) error
- func UpdateClanLeaderboards(clan int, mode int, rating float64) error
- func UpdateClanStats(clan int, mode int, rating float64, acc float64) error
- func UpdateCountryLeaderboard(u *User, mode common.Mode, rating float64) error
- func UpdateGlobalLeaderboard(u *User, mode common.Mode, rating float64) error
- func UpdateScoreboardCache(s *Score, m *Map) error
- func UpdateUserLatestActivity(id int) error
- type ActivityFeed
- type ClanScore
- type FirstPlaceScore
- type Map
- type RowScanner
- type Score
- func ClanScoresToScores(clanScores []ClanScore) []Score
- func GetClanOverallScoresConverted(clan int, mode int) ([]Score, error)
- func GetClanPlayerScores(clan int, md5 string) ([]Score, error)
- func GetPersonalBestScore(u *User, m *Map) (Score, error)
- func GetScoreByReplayMD5(u *User, md5 string) (Score, error)
- func GetUserTopScores(id int, mode common.Mode) ([]Score, error)
- type User
- type UserStats
Constants ¶
This section is empty.
Variables ¶
var Redis *redis.Client
var RedisCtx context.Context = context.Background()
var SQL *sql.DB
Functions ¶
func CalculateClanOverallAccuracy ¶
Calculates the overall accuracy of a clan
func CalculateClanOverallRating ¶
Calculates the overall rating of a clan
func CalculateOverallAccuracy ¶
CalculateOverallAccuracy calculates the overall accuracy from a list of scores Assumes that the scores are sorted by performance rating
func CalculateOverallRating ¶
CalculateOverallRating Calculates the overall rating of a list of scores. Assumes that scores are sorted by performance rating
func CloseSQLConnection ¶
func CloseSQLConnection()
CloseSQLConnection Closes the existing SQL connection
func GetCountryLeaderboardKey ¶
GetCountryLeaderboardKey Gets the country leaderboard redis key for a country and mode
func GetGlobalLeaderboardKey ¶
GetGlobalLeaderboardKey Gets the global leaderboard redis key for a game mode
func IncrementMapPlayCount ¶
IncrementMapPlayCount Increments the play count & fail count of the map in the db & ES TODO: Update ES
func InsertActivityFeed ¶
func InsertActivityFeed(userId int, feed ActivityFeed, value string, mapsetId int) error
InsertActivityFeed Adds an activity feed log to the database
func InsertClanScore ¶
Inserts a new clan score to the database (or updates it if it already exists)
func UpdateClanLeaderboards ¶
Update a clan's rating in redis
func UpdateClanStats ¶
Updates a clan's stats in the database
func UpdateCountryLeaderboard ¶
UpdateCountryLeaderboard Updates the country leaderboard for a given user and game mode
func UpdateGlobalLeaderboard ¶
UpdateGlobalLeaderboard Updates the global leaderboard for a user in redis
func UpdateScoreboardCache ¶
UpdateScoreboardCache Updates the redis cache for a particular score
func UpdateUserLatestActivity ¶
UpdateUserLatestActivity Updates a user's latest activity to the current time
Types ¶
type ActivityFeed ¶
type ActivityFeed int
const ( ActivityFeedRegistered ActivityFeed = iota ActivityFeedUploadedMapset ActivityFeedUpdatedMapset ActivityFeedRankedMapset ActivityFeedDeniedMapset ActivityFeedAchievedFirstPlace ActivityFeedLostFirstPlace ActivityFeedUnlockedAchievement ActivityFeedDonated ActivityFeedReceivedDonatorGift )
type ClanScore ¶
type ClanScore struct { Id int ClanId int Mode int MapMD5 string OverallRating float64 OverallAccuracy float64 }
func CalculateClanMapScore ¶
Calculates an individual score on a map from a clan
func GetClanOverallScores ¶
Retrieves a clan's top scores
type FirstPlaceScore ¶
func GetFirstPlaceScore ¶
func GetFirstPlaceScore(md5 string) (FirstPlaceScore, error)
GetFirstPlaceScore Retrieves a first place score for a given map
func NewFirstPlaceScore ¶
func NewFirstPlaceScore(md5 string, userId int, scoreId int, rating float64) FirstPlaceScore
func (*FirstPlaceScore) Insert ¶
func (s *FirstPlaceScore) Insert() error
Insert Inserts this first place score into the database
func (*FirstPlaceScore) Update ¶
func (s *FirstPlaceScore) Update() error
Update Updates the first place score in the database
type Map ¶
type Map struct { Id int MapsetId int MD5 string AlternativeMD5 sql.NullString CreatorId int CreatorUsername string GameMode common.Mode RankedStatus common.RankedStatus Length int32 Artist string Title string DifficultyName string DifficultyRating float64 ClanRanked bool CountHitObjectNormal int32 CountHitObjectLong int32 }
func GetMapById ¶
GetMapById Fetches a map in the database by its id
func GetMapByMD5 ¶
GetMapByMD5 Fetches a map in the database by its MD5 hash
type RowScanner ¶
type RowScanner interface {
Scan(dest ...interface{}) error
}
type Score ¶
type Score struct { Id int UserId int MapMD5 string ReplayMD5 string Timestamp int64 Mode common.Mode PersonalBest bool PerformanceRating float64 Mods common.Mods Failed bool TotalScore int32 Accuracy float32 MaxCombo int CountMarv int CountPerf int CountGreat int CountGood int CountOkay int CountMiss int Grade common.Grade ScrollSpeed int TimePlayStart int64 TimePlayEnd int64 Ip string ExecutingAssembly string EntryAssembly string QuaverVersion string PauseCount int PerformanceProcessorVersion string DifficultyProcessorVersion string IsDonatorScore bool TournamentGameId sql.NullInt32 ClanId sql.NullInt32 }
func ClanScoresToScores ¶
Converts a slice of ClanScore to db.Score
func GetClanOverallScoresConverted ¶
Returns a converted db.Score object from []ClanScore This is so we can pass it into calculation methods that require that struct
func GetClanPlayerScores ¶
Retrieves a clan's scores on a particualr map MariaDB hack... https://stackoverflow.com/questions/6572110/order-by-date-and-time-before-group-by-name-in-mysql
func GetPersonalBestScore ¶
GetPersonalBestScore Fetches a user's personal best score on a map
func GetScoreByReplayMD5 ¶
GetScoreByReplayMD5 Fetches a user's score by replay MD5 in the database
type User ¶
type User struct { Id int SteamId string Username string Allowed bool Privileges int64 UserGroups int64 LatestActivity int64 Country string CheckedPreviousAchievements bool AvatarURL sql.NullString ClanId sql.NullInt32 ShadowBanned bool }
func GetUserById ¶
GetUserById Fetches a user object by their id
func (*User) GetAvatarURL ¶
func (*User) GetCountryRank ¶
GetCountryRank Retrieves a user's country rank for a specific game mode
func (*User) GetGlobalRank ¶
GetGlobalRank Retrieves a user's global rank for a specific game mode
type UserStats ¶
type UserStats struct { Mode common.Mode UserId int TotalScore int64 RankedScore int64 OverallAccuracy float64 OverallRating float64 PlayCount int32 FailCount int32 MaxCombo int32 ReplaysWatched int32 TotalMarv int32 TotalPerf int32 TotalGreat int32 TotalGood int32 TotalOkay int32 TotalMiss int32 TotalPauses int MultiplayerWins int MultiplayerLosses int MultiplayerTies int CountGradeX int CountGradeSS int CountGradeS int CountGradeA int CountGradeB int CountGradeC int CountGradeD int }
func GetUserStats ¶
GetUserStats Retrieves a user's stats for a game mode
func (*UserStats) GetTotalHits ¶
GetTotalHits Returns a sum of all hits (misses do onot count)
func (*UserStats) UpdateDatabase ¶
UpdateDatabase Updates the user's stats in the database