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
})).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 (
"github.com/muety/wakapi/models"
"strings"
"time"
)
type LeaderboardViewModel struct {
@ -69,3 +70,7 @@ func (s *LeaderboardViewModel) LangIcon(lang string) string {
}
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>
{{ end }}
</ol>
<p class="text-sm pt-8">Last Updated: {{ .LastUpdate | datetime }}</p>
{{ else }}
<p>
<span class="iconify inline text-white text-base" data-icon="twemoji:frowning-face"></span>&nbsp;