From c3dfe194bd3b2cf8405eadfb17bd978ca3150760 Mon Sep 17 00:00:00 2001 From: Erik Winter Date: Tue, 10 Dec 2024 07:50:11 +0100 Subject: [PATCH] wip --- sync/service/recur.go | 11 ++++++----- sync/service/recur_test.go | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 sync/service/recur_test.go diff --git a/sync/service/recur.go b/sync/service/recur.go index c69d10c..deaae4e 100644 --- a/sync/service/recur.go +++ b/sync/service/recur.go @@ -19,22 +19,22 @@ func NewRecur(repoRecur Recurrer, repoSync Syncer, interval time.Duration, logge repoSync: repoSync, logger: logger, } - go r.run(interval) + go r.Run(interval) return r } -func (r *Recur) run(interval time.Duration) { +func (r *Recur) Run(interval time.Duration) { ticker := time.NewTicker(interval) for range ticker.C { - if err := r.recur(); err != nil { + if err := r.Recur(); err != nil { r.logger.Error("could not recur", "error", err) } } } -func (r *Recur) recur() error { +func (r *Recur) Recur() error { items, err := r.repoRecur.RecursBefore(time.Now()) if err != nil { return err @@ -45,7 +45,8 @@ func (r *Recur) recur() error { if err != nil { return err } - ne.Start = i.RecurNext // TODO something with time + y, m, d := i.RecurNext.Date() + ne.Start = time.Date(y, m, d, ne.Start.Hour(), ne.Start.Minute(), 0, 0, time.UTC) ni, err := ne.Item() if err != nil { return err diff --git a/sync/service/recur_test.go b/sync/service/recur_test.go new file mode 100644 index 0000000..0fee6f5 --- /dev/null +++ b/sync/service/recur_test.go @@ -0,0 +1 @@ +package main_test