feat: implement cron worker for automated daily statistics and weekly database backups
All checks were successful
Build and Release / release (push) Successful in 1m29s

This commit is contained in:
2026-05-11 11:08:49 +07:00
parent 2873e42eab
commit b94618c7d7

View File

@@ -105,14 +105,14 @@ func main() {
// Run initially on startup // Run initially on startup
runStatistics(context.Background(), statisticRepo) runStatistics(context.Background(), statisticRepo)
s, err := gocron.NewScheduler() s, err := gocron.NewScheduler(gocron.WithLocation(time.Local))
if err != nil { if err != nil {
log.Fatal().Err(err).Msg("Failed to create scheduler") log.Fatal().Err(err).Msg("Failed to create scheduler")
} }
// Run statistics every day at midnight (00:00) // Run statistics every day at 01:00 AM
_, err = s.NewJob( _, err = s.NewJob(
gocron.DailyJob(1, gocron.NewAtTimes(gocron.NewAtTime(0, 0, 0))), gocron.DailyJob(1, gocron.NewAtTimes(gocron.NewAtTime(1, 0, 0))),
gocron.NewTask(func() { gocron.NewTask(func() {
runStatistics(context.Background(), statisticRepo) runStatistics(context.Background(), statisticRepo)
}), }),