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

chore: display leaderboard update time

This commit is contained in:
Ferdinand Mütsch 2022-10-06 15:30:18 +02:00
parent dec5849661
commit ef87445e43
5 changed files with 17 additions and 1 deletions

View File

@ -68,3 +68,13 @@ func (l Leaderboard) TopKeysByUser(by uint8, userId string) []string {
return item.UserID == userId return item.UserID == userId
})).TopKeys(by) })).TopKeys(by)
} }
func (l Leaderboard) LastUpdate() time.Time {
lastUpdate := time.Time{}
for _, item := range l {
if item.CreatedAt.T().After(lastUpdate) {
lastUpdate = item.CreatedAt.T()
}
}
return lastUpdate
}

View File

@ -3,6 +3,7 @@ package view
import ( import (
"github.com/muety/wakapi/models" "github.com/muety/wakapi/models"
"strings" "strings"
"time"
) )
type LeaderboardViewModel struct { type LeaderboardViewModel struct {
@ -69,3 +70,7 @@ func (s *LeaderboardViewModel) LangIcon(lang string) string {
} }
return "" return ""
} }
func (s *LeaderboardViewModel) LastUpdate() time.Time {
return models.Leaderboard(s.Items).LastUpdate()
}

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -77,6 +77,7 @@
</li> </li>
{{ end }} {{ end }}
</ol> </ol>
<p class="text-sm pt-8">Last Updated: {{ .LastUpdate | datetime }}</p>
{{ else }} {{ else }}
<p> <p>
<span class="iconify inline text-white text-base" data-icon="twemoji:frowning-face"></span>&nbsp; <span class="iconify inline text-white text-base" data-icon="twemoji:frowning-face"></span>&nbsp;