From f2c70224697c6532035eccc69fdb5bde8c8b9379 Mon Sep 17 00:00:00 2001 From: idanoo Date: Mon, 30 Jan 2023 12:33:16 +1300 Subject: [PATCH] Order by counts --- internal/gomastodonstats/main.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/gomastodonstats/main.go b/internal/gomastodonstats/main.go index 3490882..700ea09 100644 --- a/internal/gomastodonstats/main.go +++ b/internal/gomastodonstats/main.go @@ -1,6 +1,9 @@ package gomastodonstats -import "log" +import ( + "log" + "sort" +) func Run() { log.Println("Fetching counts") @@ -14,7 +17,12 @@ func Run() { // Write to DB updatedMetrics := persistMetrics(metrics) if len(updatedMetrics) > 0 { - // sendToMatrix(updatedMetrics) + // Sort by counts! + sort.Slice(updatedMetrics, func(i, j int) bool { + return updatedMetrics[i].MetricValue < updatedMetrics[j].MetricValue + }) + + sendToMatrix(updatedMetrics) postToMastodon(updatedMetrics) } }