Skip to content

Commit

Permalink
feat: use unmerged preview implement to check cron scheduler range
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanceLi committed Aug 19, 2024
1 parent 457fc17 commit fffad35
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 40 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ require (
sigs.k8s.io/controller-runtime v0.13.1
)

replace github.com/robfig/cron/v3 v3.0.1 => github.com/juliev0/cron/v3 v3.0.2-0.20220310063235-7181f74c09e9 // https://github.com/robfig/cron/pull/437

require (
cloud.google.com/go v0.97.0 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/juliev0/cron/v3 v3.0.2-0.20220310063235-7181f74c09e9 h1:Pa9SanmckPLZ4HeHEl/OGxXPKRg5NpNx3xmM8wDN/LE=
github.com/juliev0/cron/v3 v3.0.2-0.20220310063235-7181f74c09e9/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
Expand Down Expand Up @@ -310,8 +312,6 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
Expand Down
36 changes: 0 additions & 36 deletions utils/cron/cron.go

This file was deleted.

4 changes: 2 additions & 2 deletions utils/timerange/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"time"

"github.com/xscaling/wing/utils/cron"
"github.com/robfig/cron/v3"
)

var (
Expand Down Expand Up @@ -70,7 +70,7 @@ func NewCronScheduler(timezone *time.Location, start, end string) (*CronSchedule

func (s *CronScheduler) Contains(when time.Time) bool {
whenInTimezone := when.In(s.timezone)
lastStart := s.startSched.Previous(whenInTimezone)
lastStart := s.startSched.Prev(whenInTimezone)
nextStart := s.startSched.Next(whenInTimezone)
nextEnd := s.endSched.Next(whenInTimezone)
// when in [lastStart, nextEnd) and nextStart > nextEnd
Expand Down

0 comments on commit fffad35

Please sign in to comment.