Order by counts

This commit is contained in:
idanoo 2023-01-30 12:33:16 +13:00
parent d927f1c5a1
commit f2c7022469
Signed by: idanoo
GPG key ID: 387387CDBC02F132

View file

@ -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)
}
}