feat(api): admin job-events feed with error messages for terminal log view #879

Merged
chris merged 1 commit from feat/admin-job-events-api into main 2026-09-25 22:36:14 +02:00
Owner

Summary

Adds GET /api/admin/job-events — a keyset-paginated, newest-first event feed of background job runs with failure messages, for the terminal-style admin log view. Complements GET /api/admin/job-runs.

Contract

  • limit (1..200, default 100, clamped), jobType (exact), status (failed|completed|cancelled|running|queued), before (ISO-8601 Instant keyset cursor, occurredAt strictly < before)
  • Response { events, hasMore, nextBefore }; events sorted occurredAt DESC, id DESC
  • Sources: worker_jobs (wj-*), album_suggestion_runs (asr-*), retrospective_runs (rr-*), export_jobs (exp-*) via UNION ALL, each branch LIMIT-bounded
  • Failure message: processing_issues.message (guarded by status='failed') else worker_job_results issue payload message; run tables expose error_message
  • Churn job types excluded by default; included when status=failed or an explicit jobType filter names them
  • Only run-table rows in terminal or running states are emitted

Notes

  • processing_issues is read via a per-row correlated subquery on the small worker_jobs result set (no index on source_id; avoids a big join over 78k issue rows).
  • Payload fallback is read as text and parsed in Java, so the SQL stays portable to the H2 test database (H2 has no ->>).

Migration

  • V139 adds idx_worker_jobs_updated_at (updated_at DESC) and idx_worker_jobs_job_type_updated_at (job_type, updated_at DESC) (plain CREATE INDEX IF NOT EXISTS; Flyway runs in-txn).

Verification

  • rtk ./gradlew :apps:api:compileJava — green
  • rtk ./gradlew :apps:api:test --tests '*JobEvent*' --tests '*JobRun*' — 19 tests green (JobEventsServiceTest 10, JobEventsControllerTest 3, JobRuns* 6)
  • Production query shape validated with EXPLAIN against live PostgreSQL (read-only)
## Summary Adds `GET /api/admin/job-events` — a keyset-paginated, newest-first event feed of background job runs with failure messages, for the terminal-style admin log view. Complements `GET /api/admin/job-runs`. ### Contract - `limit` (1..200, default 100, clamped), `jobType` (exact), `status` (failed|completed|cancelled|running|queued), `before` (ISO-8601 Instant keyset cursor, occurredAt strictly < before) - Response `{ events, hasMore, nextBefore }`; events sorted `occurredAt DESC, id DESC` - Sources: `worker_jobs` (`wj-*`), `album_suggestion_runs` (`asr-*`), `retrospective_runs` (`rr-*`), `export_jobs` (`exp-*`) via `UNION ALL`, each branch LIMIT-bounded - Failure message: `processing_issues.message` (guarded by `status='failed'`) else `worker_job_results` issue payload `message`; run tables expose `error_message` - Churn job types excluded by default; included when `status=failed` or an explicit `jobType` filter names them - Only run-table rows in terminal or running states are emitted ### Notes - `processing_issues` is read via a per-row correlated subquery on the small worker_jobs result set (no index on source_id; avoids a big join over 78k issue rows). - Payload fallback is read as text and parsed in Java, so the SQL stays portable to the H2 test database (H2 has no `->>`). ### Migration - V139 adds `idx_worker_jobs_updated_at (updated_at DESC)` and `idx_worker_jobs_job_type_updated_at (job_type, updated_at DESC)` (plain CREATE INDEX IF NOT EXISTS; Flyway runs in-txn). ### Verification - `rtk ./gradlew :apps:api:compileJava` — green - `rtk ./gradlew :apps:api:test --tests '*JobEvent*' --tests '*JobRun*'` — 19 tests green (JobEventsServiceTest 10, JobEventsControllerTest 3, JobRuns* 6) - Production query shape validated with EXPLAIN against live PostgreSQL (read-only)
feat(api): admin job-events feed with error messages for terminal log view
All checks were successful
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 2s
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 1m51s
95741d3562
chris merged commit 47fb108a23 into main 2026-09-25 22:36:14 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!879
No description provided.