feat: add PrevN/NextN schedule introspection to web API#495
Conversation
Summary of ChangesHello @CybotTM, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
✅ Mutation Testing ResultsMutation Score: 100.00% (threshold: 60%)
What is mutation testing?Mutation testing measures test quality by introducing small changes (mutations) to the code and checking if tests detect them. A higher score means better test effectiveness.
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This pull request adds schedule introspection capabilities to the web API by exposing the next 5 and previous 5 scheduled execution times for each job. It leverages go-cron v0.12.0's NextN and PrevN APIs to provide better visibility into job scheduling patterns.
Changes:
- Added
NextRunsandPrevRunsarray fields to the/api/jobsresponse containing 5 upcoming and 5 previous schedule times - Implemented
EntryByNamemethod in the Scheduler for safe cron entry lookups - Properly handle edge cases where triggered, disabled, and removed jobs return empty run arrays
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| core/scheduler.go | Added EntryByName method with nil-safe guard for looking up cron entries by job name |
| web/server.go | Enhanced apiJob struct and buildAPIJobs to compute and populate next/prev runs using go-cron's introspection APIs |
| web/server_test.go | Added comprehensive test coverage for next/prev runs functionality including edge cases for triggered, disabled, and removed jobs |
Addresses Copilot review feedback: document the new array fields in the Job schema alongside the existing nextRun field.
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable feature for job introspection by adding next and previous run times to the API response. The implementation is well-executed and accompanied by a comprehensive set of tests. I have one suggestion regarding code consistency in the disabledJobsHandler to prevent duplication and ensure all apiJob fields are populated uniformly. Additionally, it would be beneficial to update the API documentation in docs/API.md to reflect these new fields (nextRuns and prevRuns) in the /api/jobs endpoint response, ensuring users are aware of this new capability.
Merging this PR will degrade performance by 91.24%
Performance Changes
Comparing Footnotes |
|
🚀 Released in v0.21.0 Thank you for your contribution! 🙏 This is now available in the latest release. Please test and verify everything works as expected in your environment. If you encounter any issues, please open a new issue. |
Summary
NextRunsandPrevRunsarrays (5 entries each) to the/api/jobsresponse using go-cron v0.12.0'sNextN/PrevNintrospection APIsEntryByNamemethod toSchedulerfor looking up cron entries by job name with nil-safe guardTest Plan
TestJobsEndpointNextPrevRuns- verifies next/prev runs populatedTestJobsEndpointTriggeredJobEmptyRuns- triggered jobs have empty runsTestDisabledJobsEndpointEmptyRuns- disabled jobs have empty runsTestRemovedJobsEndpointEmptyRuns- removed jobs have empty runsTestJobsEndpointNextPrevRunsJSONFormat- JSON format validationgolangci-lintclean (0 issues)Closes #493