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:
parent
0884f620f1
commit
9fd9ffbb3d
@ -38,6 +38,11 @@ type AggregationJob struct {
|
|||||||
|
|
||||||
// Schedule a job to (re-)generate summaries every day shortly after midnight
|
// Schedule a job to (re-)generate summaries every day shortly after midnight
|
||||||
func (srv *AggregationService) Schedule() {
|
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 := gocron.NewScheduler(time.Local)
|
||||||
s.Every(1).Day().At(srv.config.App.AggregationTime).Do(srv.Run, map[string]bool{})
|
s.Every(1).Day().At(srv.config.App.AggregationTime).Do(srv.Run, map[string]bool{})
|
||||||
s.StartBlocking()
|
s.StartBlocking()
|
||||||
@ -144,7 +149,7 @@ func generateUserJobs(userId string, from time.Time, jobs chan<- *AggregationJob
|
|||||||
var to time.Time
|
var to time.Time
|
||||||
|
|
||||||
// Go to next day of either user's first heartbeat or latest aggregation
|
// 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 = time.Date(
|
||||||
from.Year(),
|
from.Year(),
|
||||||
from.Month(),
|
from.Month(),
|
||||||
|
Loading…
Reference in New Issue
Block a user