refactor(discovery): unify thumbnail pipeline under single generic job type #666

Merged
chris merged 1 commit from fix/generic-discovery-thumbnail into main 2026-07-21 00:28:46 +02:00
Owner

Summary

PR 2 of the generic discovery thumbnail pipeline. PR 1 (merged, v1.21.16) backfilled face bbox into occurrence_ref.scope. This PR makes the pipeline fully generic.

What changed

Generic enqueue (WorkerJobEnqueueService):

  • New enqueueMissingDiscoveryThumbnailJobs[ForMedia]() — queries class_instance_occurrences.occurrence_ref for scope/bbox. Works for any domain.
  • Deprecates per-domain enqueueMissingFaceThumbnailJobs and enqueueMissingPlantThumbnailJobs.

Generic worker handler (MediaJobHandlers):

  • New generateDiscoveryThumbnail() dispatches on generate_discovery_thumbnail job type.
  • Renamed renderFaceThumbnailJpeg → renderRegionThumbnailJpeg (method was already generic).
  • Deprecates generateFaceThumbnail and generatePlantThumbnail.

Generic result acceptance (WorkerResultService):

  • New acceptDiscoveryThumbnail() stores derived asset with derived_type = 'discovery_thumbnail'.
  • Triggers in acceptFaceCandidates, acceptDiscoveryCandidate, acceptClassInstanceCandidate now call generic enqueue method.
  • Deprecates acceptFaceThumbnail and acceptPlantThumbnail.

Generic endpoint (DerivedAssetController):

  • GET /api/media/{mediaItemId}/instances/{classInstanceId}/thumbnail — domain-agnostic.

Explore page: Removed bboxCropStyle on cards — uses precomputed crop URLs only.

URL fix: ClassInstanceDiscoveryService repCroppedUrl now uses /instances/ endpoint for all domains.

Tests: Updated MLResultAcceptanceTest and MediaMaintenanceServiceTest to match generic pipeline.

Docs: Updated ADR 0094 and design spec with generic pipeline architecture section.

Files changed (13)

File Change
WorkerJobEnqueueService.java Generic enqueue methods, deprecations
MediaJobHandlers.java Generic handler, rename, deprecations
WorkerResultService.java Generic acceptance, triggers, deprecations
DerivedAssetController.java New generic endpoint
ClassInstanceDiscoveryService.java Fix repCroppedUrl to /instances/
MediaMaintenanceService.java Replace per-domain calls
WorkerResultBackfillRunner.java Replace per-domain calls
explore/+page.svelte Remove bboxCropStyle, use URLs only
MLResultAcceptanceTest.java Override new generic method
MediaMaintenanceServiceTest.java Update expected job types
0094-*.json Add rules (10), (11)
2026-07-20-*.md Generic pipeline section
gradle.properties v1.21.17

Verification

  • ✅ ./gradlew :apps:api:compileJava — BUILD SUCCESSFUL
  • ✅ ./gradlew :apps:worker-media:compileJava — BUILD SUCCESSFUL
  • ✅ ./gradlew :apps:api:test — 728 tests, 0 failures
  • ✅ npx svelte-check — 0 errors (20 pre-existing warnings)
## Summary PR 2 of the generic discovery thumbnail pipeline. PR 1 (merged, v1.21.16) backfilled face bbox into occurrence_ref.scope. This PR makes the pipeline fully generic. ### What changed **Generic enqueue** (`WorkerJobEnqueueService`): - New `enqueueMissingDiscoveryThumbnailJobs[ForMedia]()` — queries `class_instance_occurrences.occurrence_ref` for scope/bbox. Works for any domain. - Deprecates per-domain `enqueueMissingFaceThumbnailJobs` and `enqueueMissingPlantThumbnailJobs`. **Generic worker handler** (`MediaJobHandlers`): - New `generateDiscoveryThumbnail()` dispatches on `generate_discovery_thumbnail` job type. - Renamed `renderFaceThumbnailJpeg` → `renderRegionThumbnailJpeg` (method was already generic). - Deprecates `generateFaceThumbnail` and `generatePlantThumbnail`. **Generic result acceptance** (`WorkerResultService`): - New `acceptDiscoveryThumbnail()` stores derived asset with `derived_type = 'discovery_thumbnail'`. - Triggers in `acceptFaceCandidates`, `acceptDiscoveryCandidate`, `acceptClassInstanceCandidate` now call generic enqueue method. - Deprecates `acceptFaceThumbnail` and `acceptPlantThumbnail`. **Generic endpoint** (`DerivedAssetController`): - `GET /api/media/{mediaItemId}/instances/{classInstanceId}/thumbnail` — domain-agnostic. **Explore page**: Removed `bboxCropStyle` on cards — uses precomputed crop URLs only. **URL fix**: `ClassInstanceDiscoveryService` repCroppedUrl now uses `/instances/` endpoint for all domains. **Tests**: Updated `MLResultAcceptanceTest` and `MediaMaintenanceServiceTest` to match generic pipeline. **Docs**: Updated ADR 0094 and design spec with generic pipeline architecture section. ### Files changed (13) | File | Change | |------|--------| | `WorkerJobEnqueueService.java` | Generic enqueue methods, deprecations | | `MediaJobHandlers.java` | Generic handler, rename, deprecations | | `WorkerResultService.java` | Generic acceptance, triggers, deprecations | | `DerivedAssetController.java` | New generic endpoint | | `ClassInstanceDiscoveryService.java` | Fix repCroppedUrl to /instances/ | | `MediaMaintenanceService.java` | Replace per-domain calls | | `WorkerResultBackfillRunner.java` | Replace per-domain calls | | `explore/+page.svelte` | Remove bboxCropStyle, use URLs only | | `MLResultAcceptanceTest.java` | Override new generic method | | `MediaMaintenanceServiceTest.java` | Update expected job types | | `0094-*.json` | Add rules (10), (11) | | `2026-07-20-*.md` | Generic pipeline section | | `gradle.properties` | v1.21.17 | ### Verification - ✅ `./gradlew :apps:api:compileJava` — BUILD SUCCESSFUL - ✅ `./gradlew :apps:worker-media:compileJava` — BUILD SUCCESSFUL - ✅ `./gradlew :apps:api:test` — 728 tests, 0 failures - ✅ `npx svelte-check` — 0 errors (20 pre-existing warnings)
refactor(discovery): unify thumbnail pipeline under single generic job type
All checks were successful
Build and Deploy / Detect changed services and test scopes (push) Successful in 6s
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Smoke ML worker (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 / 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 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 2m3s
022e1a84a2
PR 2 of the generic discovery thumbnail pipeline.

- Add generic enqueue method: enqueueMissingDiscoveryThumbnailJobs[ForMedia]()
  queries class_instance_occurrences.occurrence_ref for scope/bbox.
  Replaces per-domain face/plant enqueue methods.
- Add generic worker handler: generateDiscoveryThumbnail dispatches on
  'generate_discovery_thumbnail' job type.
- Add generic result acceptance: acceptDiscoveryThumbnail stores derived
  asset with derived_type='discovery_thumbnail'.
- Add generic endpoint: GET /api/media/{id}/instances/{id}/thumbnail
- Replace per-domain triggers in acceptFaceCandidates, acceptDiscoveryCandidate,
  acceptClassInstanceCandidate with generic enqueueMissingDiscoveryThumbnailJobsForMedia.
- Replace per-domain triggers in MediaMaintenanceService with generic method.
- Replace per-domain backfill in WorkerResultBackfillRunner with generic method.
- Rename renderFaceThumbnailJpeg -> renderRegionThumbnailJpeg (method already generic).
- Update explore page: remove bboxCropStyle on cards, use precomputed crop URLs only.
- Fix repCroppedUrl to use /instances/ endpoint for all domains.
- Deprecate old domain-specific methods (kept functional for in-flight jobs).
- Update ADR 0094 and design spec with generic pipeline architecture.
- Bump version to 1.21.17.
chris merged commit 21b7fb5a29 into main 2026-07-21 00:28:46 +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!666
No description provided.