Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CronTrigger.NextFireTime() implementation #52

Merged
merged 14 commits into from
Jun 2, 2023

Conversation

joaquinrovira
Copy link
Contributor

Proposed fix for issue #51. I have also updated and validated the tests in cron_test.go with Cronmaker, an online website that uses the original Quartz library to return the next fire times of a given Cron expression.

Hope this helps, and I welcome any discussion regarding the implementation.

@lagzi
Copy link

lagzi commented May 10, 2023

Hey @reugn, will this be considered soon? I'm currently considering using this wonderful library and this seems like a crucial bug

@joaquinrovira
Copy link
Contributor Author

@reugn, if you have no intention to maintain the project, could you kindly clarify your position? Perhaps we can transfer it to a community-owned repository. It would be a great shame to abandon such a valuable project.

As a sidenote, the cron-related functionality could be moved to a separate library. After a quick search, it appears that the only other project that offers similar functionality is robfig/cron, which has been unmaintained since January 2021, with numerous pending pull requests and issues.

@codecov-commenter
Copy link

codecov-commenter commented May 13, 2023

Codecov Report

Merging #52 (46e150c) into master (5affccf) will increase coverage by 0.50%.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master      #52      +/-   ##
==========================================
+ Coverage   85.39%   85.90%   +0.50%     
==========================================
  Files           7        8       +1     
  Lines         678      532     -146     
==========================================
- Hits          579      457     -122     
+ Misses         74       53      -21     
+ Partials       25       22       -3     
Impacted Files Coverage Δ
quartz/util.go 90.00% <ø> (+1.11%) ⬆️
quartz/cron.go 77.08% <100.00%> (-3.77%) ⬇️
quartz/csm.go 100.00% <100.00%> (ø)

Copy link
Owner

@reugn reugn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @joaquinrovira,
Thanks for your time to look into the project and your contribution.
Since the PR is a voluminous rework, I had to postpone reviewing it.
Here are my initial comments before we can merge.

  • Please add documentation for all new exported items (possibly make the csm package internal)
  • Add a doc.go to the csm package with a brief description of the functionality
  • Address linter warnings
  • Add an empty line between methods where it is missing

quartz/csm.go Outdated
CSM "github.com/reugn/go-quartz/quartz/csm"
)

func MakeCSMFromFields(prev time.Time, fields []*cronField) *CSM.CronStateMachine {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be private

quartz/csm.go Outdated
csm := CSM.NewCronStateMachine(second, minute, hour, day, month, year)
return csm
}
func MakeCSMFromCronTrigger(prev time.Time, trigger *CronTrigger) *CSM.CronStateMachine {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be private

@joaquinrovira
Copy link
Contributor Author

On it! Thank you for your time.

@joaquinrovira joaquinrovira requested a review from reugn May 20, 2023 14:26
@joaquinrovira
Copy link
Contributor Author

joaquinrovira commented May 20, 2023

Fixed the issues mentioned and added an explanation in internal/csm/doc.go.

@reugn
Copy link
Owner

reugn commented May 26, 2023

@joaquinrovira, please run gofmt -w quartz/internal/csm/doc.go. I plan to review and merge over the next week.

@joaquinrovira
Copy link
Contributor Author

@joaquinrovira, please run gofmt -w quartz/internal/csm/doc.go. I plan to review and merge over the next week.

Done.

Copy link
Owner

@reugn reugn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @joaquinrovira.

quartz/internal/csm/node.go Outdated Show resolved Hide resolved
quartz/internal/csm/util.go Outdated Show resolved Hide resolved
@reugn reugn merged commit 93e7c40 into reugn:master Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants