1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-16 18:45:17 +00:00

fix: run jobs at interval instead of specific time (#585)

This commit is contained in:
Alessandro (Ale) Segala
2025-05-29 08:15:35 -07:00
committed by GitHub
parent 3d402fc0ca
commit 6d6dc6646a
7 changed files with 105 additions and 46 deletions

View File

@@ -9,6 +9,7 @@ import (
"time"
backoff "github.com/cenkalti/backoff/v5"
"github.com/go-co-op/gocron/v2"
"github.com/pocket-id/pocket-id/backend/internal/common"
"github.com/pocket-id/pocket-id/backend/internal/service"
@@ -22,11 +23,12 @@ func (s *Scheduler) RegisterAnalyticsJob(ctx context.Context, appConfig *service
return nil
}
// Send every 24 hours
jobs := &AnalyticsJob{
appConfig: appConfig,
httpClient: httpClient,
}
return s.registerJob(ctx, "SendHeartbeat", "0 0 * * *", jobs.sendHeartbeat, true)
return s.registerJob(ctx, "SendHeartbeat", gocron.DurationJob(24*time.Hour), jobs.sendHeartbeat, true)
}
type AnalyticsJob struct {