mirror of
https://github.com/idanoo/go-mastodon-stats
synced 2025-07-01 22:02:20 +00:00
Update matrix info
This commit is contained in:
parent
ecfe777efa
commit
b3c829c381
7 changed files with 103 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
package gomastodonstats
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
@ -13,15 +14,22 @@ type metric struct {
|
|||
MetricValue int `json:"metric_value"`
|
||||
}
|
||||
|
||||
func persistMetrics(metrics []metric) {
|
||||
// persistMetrics - return any updated
|
||||
func persistMetrics(metrics []metric) []metric {
|
||||
var updatedMetrics []metric
|
||||
|
||||
startOfDay := getStartofDay()
|
||||
for _, v := range metrics {
|
||||
v.MetricTime = startOfDay
|
||||
err := insertValues(v)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
} else {
|
||||
updatedMetrics = append(updatedMetrics, v)
|
||||
}
|
||||
}
|
||||
|
||||
return updatedMetrics
|
||||
}
|
||||
|
||||
func getUserCounts() ([]metric, error) {
|
||||
|
@ -104,3 +112,13 @@ func getUserCounts() ([]metric, error) {
|
|||
|
||||
return metrics, nil
|
||||
}
|
||||
|
||||
func getPrintableString(m []metric) string {
|
||||
output := ""
|
||||
|
||||
for _, v := range m {
|
||||
output = fmt.Sprintf("%s\n%s: %d", output, v.Service, v.MetricValue)
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue