wip
This commit is contained in:
parent
c3e00455c9
commit
c3dfe194bd
|
@ -19,22 +19,22 @@ func NewRecur(repoRecur Recurrer, repoSync Syncer, interval time.Duration, logge
|
||||||
repoSync: repoSync,
|
repoSync: repoSync,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
}
|
}
|
||||||
go r.run(interval)
|
go r.Run(interval)
|
||||||
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Recur) run(interval time.Duration) {
|
func (r *Recur) Run(interval time.Duration) {
|
||||||
ticker := time.NewTicker(interval)
|
ticker := time.NewTicker(interval)
|
||||||
|
|
||||||
for range ticker.C {
|
for range ticker.C {
|
||||||
if err := r.recur(); err != nil {
|
if err := r.Recur(); err != nil {
|
||||||
r.logger.Error("could not recur", "error", err)
|
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())
|
items, err := r.repoRecur.RecursBefore(time.Now())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -45,7 +45,8 @@ func (r *Recur) recur() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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()
|
ni, err := ne.Item()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
package main_test
|
Loading…
Reference in New Issue