Skip to content

Commit

Permalink
Fix the bug that causes scheduled task not running (#18)
Browse files Browse the repository at this point in the history
Fix #17
  • Loading branch information
burakkoken authored Sep 27, 2022
1 parent 2746ffb commit 0b90d33
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 98 deletions.
99 changes: 2 additions & 97 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ orbs:
codecov: codecov/[email protected]

jobs:
build118:
build:
docker:
- image: cimg/go:1.18
steps:
Expand All @@ -23,102 +23,7 @@ jobs:
name: Run tests
command: go test -coverprofile=coverage.txt -covermode=atomic
- codecov/upload
build117:
docker:
- image: cimg/go:1.17
steps:
- checkout
- restore_cache:
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- run:
name: Install Dependencies
command: go get -t -v ./...
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- run:
name: Run tests
command: go test -coverprofile=coverage.txt -covermode=atomic
build116:
docker:
- image: cimg/go:1.16
steps:
- checkout
- restore_cache:
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- run:
name: Install Dependencies
command: go get -t -v ./...
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- run:
name: Run tests
command: go test -coverprofile=coverage.txt -covermode=atomic
build115:
docker:
- image: cimg/go:1.15
steps:
- checkout
- restore_cache:
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- run:
name: Install Dependencies
command: go get -t -v ./...
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- run:
name: Run tests
command: go test -coverprofile=coverage.txt -covermode=atomic
build114:
docker:
- image: cimg/go:1.14
steps:
- checkout
- restore_cache:
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- run:
name: Install Dependencies
command: go get -t -v ./...
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- run:
name: Run tests
command: go test -coverprofile=coverage.txt -covermode=atomic
build113:
docker:
- image: cimg/go:1.13
steps:
- checkout
- restore_cache:
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- run:
name: Install Dependencies
command: go get -t -v ./...
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- run:
name: Run tests
command: go test -coverprofile=coverage.txt -covermode=atomic
workflows:
build-workflow:
jobs:
- build118
- build117
- build116
- build115
- build114
- build113
- build
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
13 changes: 12 additions & 1 deletion trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ func (trigger *CronTrigger) NextExecutionTime(ctx TriggerContext) time.Time {
}

originalLocation := now.Location()
next := trigger.cronExpression.NextTime(now.In(trigger.location))

convertedTime := now.In(trigger.location)
newTime := time.Date(convertedTime.Year(),
convertedTime.Month(),
convertedTime.Day(),
convertedTime.Hour(),
convertedTime.Minute(),
convertedTime.Second(),
0,
trigger.location)

next := trigger.cronExpression.NextTime(newTime)
return next.In(originalLocation)
}

0 comments on commit 0b90d33

Please sign in to comment.