From 8a3ce596f5c4a89419d7f18b6574be10fcad9f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferdinand=20M=C3=BCtsch?= Date: Sun, 7 Jul 2019 10:37:17 +0200 Subject: [PATCH] Sort summary items in descending order. --- services/summary.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/summary.go b/services/summary.go index 9f96fe7..f8c6576 100644 --- a/services/summary.go +++ b/services/summary.go @@ -2,6 +2,7 @@ package services import ( "math" + "sort" "time" "github.com/jinzhu/gorm" @@ -110,5 +111,9 @@ func (srv *SummaryService) aggregateBy(heartbeats []*models.Heartbeat, summaryTy }) } + sort.Slice(items, func(i, j int) bool { + return items[i].Total > items[j].Total + }) + c <- models.SummaryItemContainer{Type: summaryType, Items: items} }