fix(backends): count disabled jobs only as paused in getJobsOverview - #1769
Open
Noethix55555 wants to merge 1 commit into
Open
fix(backends): count disabled jobs only as paused in getJobsOverview#1769Noethix55555 wants to merge 1 commit into
Noethix55555 wants to merge 1 commit into
Conversation
Disabled jobs were counted in both their computed state bucket and the paused bucket, so per-state buckets summed to total plus the number of disabled jobs. Count disabled jobs exclusively as paused across the mongo, postgres, and redis backends, matching the list view.
🦋 Changeset detectedLatest commit: 5bb5277 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1768.
Problem
getJobsOverview()double-counts disabled (paused) jobs.computeJobState()never returns'paused', so each backend counted a disabled job once in its computed-state bucket (e.g.scheduled) and again inpaused. As a result the per-state buckets summed tototal + (number of disabled jobs)rather thantotal, and the overview disagreed with the list view (queryJobstreatspausedas a mutually exclusive state). Dashboards that sum these buckets show wrong totals.Fix
Count disabled jobs exclusively as
pausedin all three backends:Applied to:
packages/mongo-backend/src/MongoJobRepository.tspackages/postgres-backend/src/PostgresJobRepository.tspackages/redis-backend/src/RedisJobRepository.tsTests
Added a regression case to the shared repository test suite (
packages/agenda/test/shared/repository-test-suite.ts) that saves a disabled job with a futurenextRunAtand asserts the per-state buckets sum tototal(and thatpaused === 1,scheduled === 0). Verified it fails onmainand passes with the fix, against all three backends (mongo via mongodb-memory-server, redis, postgres).Changeset entries added (patch) for
@agendajs/mongo-backend,@agendajs/postgres-backend, and@agendajs/redis-backend.