Skip to content

Commit

Permalink
Upgrade score APIs to also return user ids per score
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyui committed Jul 24, 2024
1 parent c40754e commit 01e005c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
17 changes: 9 additions & 8 deletions app/v1/score.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Score struct {
Rank string `json:"rank"`
Completed int `json:"completed"`
Pinned bool `json:"pinned"`
UserID int `json:"user_id"`
}

// beatmapScore is to differentiate from userScore, as beatmapScore contains
Expand Down Expand Up @@ -59,7 +60,7 @@ SELECT
scores.300_count, scores.100_count, scores.50_count,
scores.gekis_count, scores.katus_count, scores.misses_count,
scores.time, scores.play_mode, scores.accuracy, scores.pp,
scores.completed, scores.pinned,
scores.completed, scores.pinned, scores.userid,
users.id, users.username, users.register_datetime, users.privileges,
users.latest_activity, users.username_aka, users.country
Expand All @@ -74,7 +75,7 @@ SELECT
scores_relax.300_count, scores_relax.100_count, scores_relax.50_count,
scores_relax.gekis_count, scores_relax.katus_count, scores_relax.misses_count,
scores_relax.time, scores_relax.play_mode, scores_relax.accuracy, scores_relax.pp,
scores_relax.completed, scores_relax.pinned,
scores_relax.completed, scores_relax.pinned, scores.userid,
users.id, users.username, users.register_datetime, users.privileges,
users.latest_activity, users.username_aka, users.country
Expand All @@ -89,7 +90,7 @@ SELECT
scores_ap.300_count, scores_ap.100_count, scores_ap.50_count,
scores_ap.gekis_count, scores_ap.katus_count, scores_ap.misses_count,
scores_ap.time, scores_ap.play_mode, scores_ap.accuracy, scores_ap.pp,
scores_ap.completed, scores_ap.pinned,
scores_ap.completed, scores_ap.pinned, scores.userid,
users.id, users.username, users.register_datetime, users.privileges,
users.latest_activity, users.username_aka, users.country
Expand All @@ -104,7 +105,7 @@ SELECT
scores.300_count, scores.100_count, scores.50_count,
scores.gekis_count, scores.katus_count, scores.misses_count,
scores.time, scores.play_mode, scores.accuracy, scores.pp,
scores.completed, scores.pinned,
scores.completed, scores.pinned, scores.userid,
users.id, users.username, users.register_datetime, users.privileges,
users.latest_activity, users.username_aka, users.country,
Expand All @@ -125,7 +126,7 @@ SELECT
scores_relax.300_count, scores_relax.100_count, scores_relax.50_count,
scores_relax.gekis_count, scores_relax.katus_count, scores_relax.misses_count,
scores_relax.time, scores_relax.play_mode, scores_relax.accuracy, scores_relax.pp,
scores_relax.completed, scores_relax.pinned,
scores_relax.completed, scores_relax.pinned, scores.userid,
users.id, users.username, users.register_datetime, users.privileges,
users.latest_activity, users.username_aka, users.country,
Expand All @@ -146,7 +147,7 @@ SELECT
scores_ap.300_count, scores_ap.100_count, scores_ap.50_count,
scores_ap.gekis_count, scores_ap.katus_count, scores_ap.misses_count,
scores_ap.time, scores_ap.play_mode, scores_ap.accuracy, scores_ap.pp,
scores_ap.completed, scores_ap.pinned,
scores_ap.completed, scores_ap.pinned, scores.userid,
users.id, users.username, users.register_datetime, users.privileges,
users.latest_activity, users.username_aka, users.country,
Expand Down Expand Up @@ -183,7 +184,7 @@ func ScoreGET(md common.MethodData) common.CodeMessager {
&s.Count300, &s.Count100, &s.Count50,
&s.CountGeki, &s.CountKatu, &s.CountMiss,
&s.Time, &s.PlayMode, &s.Accuracy, &s.PP,
&s.Completed, &s.Pinned,
&s.Completed, &s.Pinned, &s.UserID,

&u.ID, &u.Username, &u.RegisteredOn, &u.Privileges,
&u.LatestActivity, &u.UsernameAKA, &u.Country,
Expand Down Expand Up @@ -284,7 +285,7 @@ func ScoresGET(md common.MethodData) common.CodeMessager {
&s.Count300, &s.Count100, &s.Count50,
&s.CountGeki, &s.CountKatu, &s.CountMiss,
&s.Time, &s.PlayMode, &s.Accuracy, &s.PP,
&s.Completed, &s.Pinned,
&s.Completed, &s.Pinned, &s.UserID,

&u.ID, &u.Username, &u.RegisteredOn, &u.Privileges,
&u.LatestActivity, &u.UsernameAKA, &u.Country,
Expand Down
8 changes: 4 additions & 4 deletions app/v1/user_scores.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func UserScoresBestGET(md common.MethodData) common.CodeMessager {
scores.300_count, scores.100_count, scores.50_count,
scores.gekis_count, scores.katus_count, scores.misses_count,
scores.time, scores.play_mode, scores.accuracy, scores.pp,
scores.completed, scores.pinned,
scores.completed, scores.pinned, scores.userid,
beatmaps.beatmap_id, beatmaps.beatmapset_id, beatmaps.beatmap_md5 AS beatmap_beatmap_md5,
beatmaps.song_name, beatmaps.ar, beatmaps.od,
Expand Down Expand Up @@ -87,7 +87,7 @@ func UserScoresRecentGET(md common.MethodData) common.CodeMessager {
scores.300_count, scores.100_count, scores.50_count,
scores.gekis_count, scores.katus_count, scores.misses_count,
scores.time, scores.play_mode, scores.accuracy, scores.pp,
scores.completed, scores.pinned,
scores.completed, scores.pinned, scores.userid,
beatmaps.beatmap_id, beatmaps.beatmapset_id, beatmaps.beatmap_md5 AS beatmap_beatmap_md5,
beatmaps.song_name, beatmaps.ar, beatmaps.od,
Expand Down Expand Up @@ -144,7 +144,7 @@ func UserScoresPinnedGET(md common.MethodData) common.CodeMessager {
scores.300_count, scores.100_count, scores.50_count,
scores.gekis_count, scores.katus_count, scores.misses_count,
scores.time, scores.play_mode, scores.accuracy, scores.pp,
scores.completed, scores.pinned,
scores.completed, scores.pinned, scores.userid,
beatmaps.beatmap_id, beatmaps.beatmapset_id, beatmaps.beatmap_md5 AS beatmap_beatmap_md5,
beatmaps.song_name, beatmaps.ar, beatmaps.od,
Expand Down Expand Up @@ -284,7 +284,7 @@ func scoresPuts(md common.MethodData, query string, params ...interface{}) commo
&us.Count300, &us.Count100, &us.Count50,
&us.CountGeki, &us.CountKatu, &us.CountMiss,
&us.Time, &us.PlayMode, &us.Accuracy, &us.PP,
&us.Completed, &us.Pinned,
&us.Completed, &us.Pinned, &us.UserID,

&b.BeatmapID, &b.BeatmapsetID, &b.BeatmapMD5,
&b.SongName, &b.AR, &b.OD,
Expand Down

0 comments on commit 01e005c

Please sign in to comment.