diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-12-21 16:32:05 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-21 16:32:05 +0300 |
| commit | cde64e47961823613a69e7d0185f5c36eac2e896 (patch) | |
| tree | 306ff16a27608f71b334b6fe9bf8ce25354f4e55 /backend | |
| parent | fix/frontend: map pagination fix (#246) (diff) | |
| download | lphub-cde64e47961823613a69e7d0185f5c36eac2e896.tar.gz lphub-cde64e47961823613a69e7d0185f5c36eac2e896.tar.bz2 lphub-cde64e47961823613a69e7d0185f5c36eac2e896.zip | |
fix/rankings: sort overall placements for lphub (#250)
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/handlers/home.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/backend/handlers/home.go b/backend/handlers/home.go index 714610a..5b4e246 100644 --- a/backend/handlers/home.go +++ b/backend/handlers/home.go | |||
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | "log" | 6 | "log" |
| 7 | "net/http" | 7 | "net/http" |
| 8 | "os" | 8 | "os" |
| 9 | "sort" | ||
| 9 | "strings" | 10 | "strings" |
| 10 | 11 | ||
| 11 | "lphub/database" | 12 | "lphub/database" |
| @@ -106,6 +107,15 @@ func RankingsLPHUB(c *gin.Context) { | |||
| 106 | } | 107 | } |
| 107 | } | 108 | } |
| 108 | } | 109 | } |
| 110 | // Sort the overall rankings | ||
| 111 | sort.Slice(response.Overall, func(i, j int) bool { | ||
| 112 | a := response.Overall[i] | ||
| 113 | b := response.Overall[j] | ||
| 114 | if a.TotalScore == b.TotalScore { | ||
| 115 | return a.User.SteamID < b.User.SteamID | ||
| 116 | } | ||
| 117 | return a.TotalScore < b.TotalScore | ||
| 118 | }) | ||
| 109 | 119 | ||
| 110 | placement := 1 | 120 | placement := 1 |
| 111 | ties := 0 | 121 | ties := 0 |