Implement top shares page
This commit is contained in:
+6
-6
@@ -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: "-"})
|
||||
|
||||
Reference in New Issue
Block a user