Implement top shares page

This commit is contained in:
Pijus Kamandulis
2025-06-23 14:37:06 +03:00
parent 260d2ec24b
commit d801debaf6
10 changed files with 279 additions and 9 deletions
+6 -6
View File
@@ -24,22 +24,22 @@ func GetStats(db *clover.DB) ([]models.ShareStat, error) {
stats := []models.ShareStat{}
// All-time highest
doc, _ := database.GetHighestShareInRange(db, database.CollectionName, time.Unix(0, 0))
doc, _ := database.GetHighestSharesInRange(db, database.CollectionName, time.Unix(0, 0), 1)
if doc != nil {
stats = append(stats, models.ShareStat{
Label: "All Time",
Diff: helpers.HumanDiff(doc.Get("SDiff").(float64)),
Time: helpers.ParseCreateDate(doc.Get("CreateDate").(string)).Format(time.RFC822),
Diff: helpers.HumanDiff(doc[0].SDiff),
Time: helpers.ParseCreateDate(doc[0].CreateDate).Format(time.RFC822),
})
}
for _, r := range ranges {
doc, _ := database.GetHighestShareInRange(db, database.CollectionName, r.Since)
doc, _ := database.GetHighestSharesInRange(db, database.CollectionName, r.Since, 1)
if doc != nil {
stats = append(stats, models.ShareStat{
Label: r.Label,
Diff: helpers.HumanDiff(doc.Get("SDiff").(float64)),
Time: helpers.ParseCreateDate(doc.Get("CreateDate").(string)).Format(time.RFC822),
Diff: helpers.HumanDiff(doc[0].SDiff),
Time: helpers.ParseCreateDate(doc[0].CreateDate).Format(time.RFC822),
})
} else {
stats = append(stats, models.ShareStat{Label: r.Label, Diff: "-", Time: "-"})