1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: missing summary aggregation after days without heartbeats (see #168)

This commit is contained in:
Ferdinand Mütsch 2021-04-12 23:36:22 +02:00
parent 0884f620f1
commit 9fd9ffbb3d

View File

@ -38,6 +38,11 @@ type AggregationJob struct {
// Schedule a job to (re-)generate summaries every day shortly after midnight
func (srv *AggregationService) Schedule() {
// Run once initially
if err := srv.Run(nil); err != nil {
logbuch.Fatal("failed to run AggregationJob: %v", err)
}
s := gocron.NewScheduler(time.Local)
s.Every(1).Day().At(srv.config.App.AggregationTime).Do(srv.Run, map[string]bool{})
s.StartBlocking()
@ -144,7 +149,7 @@ func generateUserJobs(userId string, from time.Time, jobs chan<- *AggregationJob
var to time.Time
// Go to next day of either user's first heartbeat or latest aggregation
from.Add(-1 * time.Second)
from = from.Add(-1 * time.Second)
from = time.Date(
from.Year(),
from.Month(),