Skip to content

Commit

Permalink
Add grades to /users/full
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyui committed Jul 24, 2024
1 parent f7520a3 commit 8c9d703
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions app/v1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,19 @@ var modesToReadable = [...]string{
}

type modeData struct {
RankedScore uint64 `json:"ranked_score"`
TotalScore uint64 `json:"total_score"`
PlayCount int `json:"playcount"`
PlayTime int `json:"playtime"`
ReplaysWatched int `json:"replays_watched"`
TotalHits int `json:"total_hits"`
Level float64 `json:"level"`
Accuracy float64 `json:"accuracy"`
PP int `json:"pp"`
GlobalLeaderboardRank *int `json:"global_leaderboard_rank"`
CountryLeaderboardRank *int `json:"country_leaderboard_rank"`
MaxCombo int `json:"max_combo"`
RankedScore uint64 `json:"ranked_score"`
TotalScore uint64 `json:"total_score"`
PlayCount int `json:"playcount"`
PlayTime int `json:"playtime"`
ReplaysWatched int `json:"replays_watched"`
TotalHits int `json:"total_hits"`
Level float64 `json:"level"`
Accuracy float64 `json:"accuracy"`
PP int `json:"pp"`
GlobalLeaderboardRank *int `json:"global_leaderboard_rank"`
CountryLeaderboardRank *int `json:"country_leaderboard_rank"`
MaxCombo int `json:"max_combo"`
Grades userGrades `json:"grades"`
}

type userStats struct {
Expand Down Expand Up @@ -259,7 +260,10 @@ func UserFullGET(md common.MethodData) common.CodeMessager {
SELECT
user_stats.ranked_score, user_stats.total_score, user_stats.playcount, user_stats.playtime,
user_stats.replays_watched, user_stats.total_hits,
user_stats.avg_accuracy, user_stats.pp, user_stats.max_combo
user_stats.avg_accuracy, user_stats.pp, user_stats.max_combo,
user_stats.xh_count, user_stats.x_count, user_stats.sh_count,
user_stats.s_count, user_stats.a_count, user_stats.b_count,
user_stats.c_count, user_stats.d_count
FROM user_stats
INNER JOIN users ON users.id = user_stats.user_id
WHERE ` + whereClause + ` AND ` + md.User.OnlyUserPublic(true) + ` AND user_stats.mode = ?
Expand All @@ -271,6 +275,9 @@ func UserFullGET(md common.MethodData) common.CodeMessager {
&r.Stats[relaxMode].STD.RankedScore, &r.Stats[relaxMode].STD.TotalScore, &r.Stats[relaxMode].STD.PlayCount, &r.Stats[relaxMode].STD.PlayTime,
&r.Stats[relaxMode].STD.ReplaysWatched, &r.Stats[relaxMode].STD.TotalHits,
&r.Stats[relaxMode].STD.Accuracy, &r.Stats[relaxMode].STD.PP, &r.Stats[relaxMode].STD.MaxCombo,
&r.Stats[relaxMode].STD.Grades.XHCount, &r.Stats[relaxMode].STD.Grades.XCount, &r.Stats[relaxMode].STD.Grades.SHCount,
&r.Stats[relaxMode].STD.Grades.SCount, &r.Stats[relaxMode].STD.Grades.ACount, &r.Stats[relaxMode].STD.Grades.BCount,
&r.Stats[relaxMode].STD.Grades.CCount, &r.Stats[relaxMode].STD.Grades.DCount,
)
switch {
case err == sql.ErrNoRows:
Expand All @@ -290,6 +297,9 @@ func UserFullGET(md common.MethodData) common.CodeMessager {
&r.Stats[relaxMode].Taiko.RankedScore, &r.Stats[relaxMode].Taiko.TotalScore, &r.Stats[relaxMode].Taiko.PlayCount, &r.Stats[relaxMode].Taiko.PlayTime,
&r.Stats[relaxMode].Taiko.ReplaysWatched, &r.Stats[relaxMode].Taiko.TotalHits,
&r.Stats[relaxMode].Taiko.Accuracy, &r.Stats[relaxMode].Taiko.PP, &r.Stats[relaxMode].Taiko.MaxCombo,
&r.Stats[relaxMode].Taiko.Grades.XHCount, &r.Stats[relaxMode].Taiko.Grades.XCount, &r.Stats[relaxMode].Taiko.Grades.SHCount,
&r.Stats[relaxMode].Taiko.Grades.SCount, &r.Stats[relaxMode].Taiko.Grades.ACount, &r.Stats[relaxMode].Taiko.Grades.BCount,
&r.Stats[relaxMode].Taiko.Grades.CCount, &r.Stats[relaxMode].Taiko.Grades.DCount,
)
switch {
case err == sql.ErrNoRows:
Expand All @@ -304,6 +314,9 @@ func UserFullGET(md common.MethodData) common.CodeMessager {
&r.Stats[relaxMode].CTB.RankedScore, &r.Stats[relaxMode].CTB.TotalScore, &r.Stats[relaxMode].CTB.PlayCount, &r.Stats[relaxMode].CTB.PlayTime,
&r.Stats[relaxMode].CTB.ReplaysWatched, &r.Stats[relaxMode].CTB.TotalHits,
&r.Stats[relaxMode].CTB.Accuracy, &r.Stats[relaxMode].CTB.PP, &r.Stats[relaxMode].CTB.MaxCombo,
&r.Stats[relaxMode].CTB.Grades.XHCount, &r.Stats[relaxMode].CTB.Grades.XCount, &r.Stats[relaxMode].CTB.Grades.SHCount,
&r.Stats[relaxMode].CTB.Grades.SCount, &r.Stats[relaxMode].CTB.Grades.ACount, &r.Stats[relaxMode].CTB.Grades.BCount,
&r.Stats[relaxMode].CTB.Grades.CCount, &r.Stats[relaxMode].CTB.Grades.DCount,
)
switch {
case err == sql.ErrNoRows:
Expand All @@ -323,6 +336,9 @@ func UserFullGET(md common.MethodData) common.CodeMessager {
&r.Stats[relaxMode].Mania.RankedScore, &r.Stats[relaxMode].Mania.TotalScore, &r.Stats[relaxMode].Mania.PlayCount, &r.Stats[relaxMode].Mania.PlayTime,
&r.Stats[relaxMode].Mania.ReplaysWatched, &r.Stats[relaxMode].Mania.TotalHits,
&r.Stats[relaxMode].Mania.Accuracy, &r.Stats[relaxMode].Mania.PP, &r.Stats[relaxMode].Mania.MaxCombo,
&r.Stats[relaxMode].Mania.Grades.XHCount, &r.Stats[relaxMode].Mania.Grades.XCount, &r.Stats[relaxMode].Mania.Grades.SHCount,
&r.Stats[relaxMode].Mania.Grades.SCount, &r.Stats[relaxMode].Mania.Grades.ACount, &r.Stats[relaxMode].Mania.Grades.BCount,
&r.Stats[relaxMode].Mania.Grades.CCount, &r.Stats[relaxMode].Mania.Grades.DCount,
)
switch {
case err == sql.ErrNoRows:
Expand Down

0 comments on commit 8c9d703

Please sign in to comment.