Skip to content

fix(backends): count disabled jobs only as paused in getJobsOverview - #1769

Open
Noethix55555 wants to merge 1 commit into
agenda:mainfrom
Noethix55555:fix/jobsoverview-paused-doublecount
Open

fix(backends): count disabled jobs only as paused in getJobsOverview#1769
Noethix55555 wants to merge 1 commit into
agenda:mainfrom
Noethix55555:fix/jobsoverview-paused-doublecount

Conversation

@Noethix55555

Copy link
Copy Markdown
Contributor

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 in paused. As a result the per-state buckets summed to total + (number of disabled jobs) rather than total, and the overview disagreed with the list view (queryJobs treats paused as a mutually exclusive state). Dashboards that sum these buckets show wrong totals.

Fix

Count disabled jobs exclusively as paused in all three backends:

if (job.disabled === true) {
  overview.paused++;
} else {
  const state = computeJobState(job, now);
  overview[state]++;
}

Applied to:

  • packages/mongo-backend/src/MongoJobRepository.ts
  • packages/postgres-backend/src/PostgresJobRepository.ts
  • packages/redis-backend/src/RedisJobRepository.ts

Tests

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 future nextRunAt and asserts the per-state buckets sum to total (and that paused === 1, scheduled === 0). Verified it fails on main and 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.

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-bot

changeset-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5bb5277

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@agendajs/mongo-backend Patch
@agendajs/postgres-backend Patch
@agendajs/redis-backend Patch
agenda-rest Patch

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

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.

getJobsOverview double-counts disabled (paused) jobs

1 participant