diff --git a/internal/gomastodonstats/main.go b/internal/gomastodonstats/main.go index 515ec82..df4520d 100644 --- a/internal/gomastodonstats/main.go +++ b/internal/gomastodonstats/main.go @@ -3,7 +3,6 @@ package gomastodonstats import ( "log" "sort" - "time" ) func Run() { @@ -23,16 +22,16 @@ func Run() { return updatedMetrics[i].MetricValue > updatedMetrics[j].MetricValue }) - sendToMatrix(updatedMetrics) + // sendToMatrix(updatedMetrics) // Only post weekly here - localTime, err := time.LoadLocation(TIMEZONE) - if err != nil { - log.Fatal(err) - } - weekday := time.Now().Local().In(localTime).Weekday() - if weekday == time.Monday { - postToMastodon(updatedMetrics) - } + // localTime, err := time.LoadLocation(TIMEZONE) + // if err != nil { + // log.Fatal(err) + // } + // weekday := time.Now().Local().In(localTime).Weekday() + // if weekday == time.Monday { + // postToMastodon(updatedMetrics) + // } } } diff --git a/internal/gomastodonstats/metrics.go b/internal/gomastodonstats/metrics.go index ab4232e..bb13521 100644 --- a/internal/gomastodonstats/metrics.go +++ b/internal/gomastodonstats/metrics.go @@ -162,6 +162,13 @@ func getLastMetric(serviceName string) int { func getLastWeekMetric(serviceName string) int { monday := getStartofDayMonday() + log.Printf( + "SELECT metric_value FROM %s WHERE metric_name = '%s' AND service = '%s' AND metric_time = '%s' LIMIT 1", + POSTGRESQL_STATS_TABLE, + METRICNAME_USERCOUNT, + serviceName, + monday, + ) val, err := runIntQuery( POSTGRESQL_STATS_DB, fmt.Sprintf( diff --git a/test.go b/test.go new file mode 100644 index 0000000..4cffe91 --- /dev/null +++ b/test.go @@ -0,0 +1,20 @@ +package main + +import ( + "log" + "time" +) + +func main() { + localTime, err := time.LoadLocation("Pacific/Auckland") + if err != nil { + log.Fatal(err) + } + // Iterate until Monday! + t := time.Now().In(localTime) + for t.Weekday() != time.Monday { + t = t.AddDate(0, 0, -1) + } + year, month, day := t.Date() + log.Println(time.Date(year, month, day, 0, 0, 0, 0, t.Location()).String()) +}