1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

feat: leaderboard aggregation functionality

feat: leaderboard ui design
This commit is contained in:
Ferdinand Mütsch
2022-10-03 23:52:22 +02:00
parent 1d7ff4bc2a
commit a27fe04919
17 changed files with 216 additions and 19 deletions

View File

@ -5,7 +5,9 @@ import "github.com/muety/wakapi/models"
type LeaderboardViewModel struct {
User *models.User
By string
Key string
Items []*models.LeaderboardItem
TopKeys []string
ApiKey string
Success string
Error string
@ -20,3 +22,19 @@ func (s *LeaderboardViewModel) WithError(m string) *LeaderboardViewModel {
s.Error = m
return s
}
func (s *LeaderboardViewModel) ColorModifier(item *models.LeaderboardItem, principal *models.User) string {
if principal != nil && item.UserID == principal.ID {
return "self"
}
if item.Rank == 1 {
return "gold"
}
if item.Rank == 2 {
return "silver"
}
if item.Rank == 3 {
return "bronze"
}
return "default"
}