feat(api): auto-trigger album suggestion runs after new imports #1270
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/album-suggestion-auto-trigger"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary\n- New
AlbumSuggestionAutoTriggerScheduler: every 5 min (configurable) it starts an album-suggestion run withtrigger_type='import_completed'for every owner who has media newer than their latest run, no active run, and whose last run is outside a 10-min debounce window.\n- Before this, runs were only ever created by the manual button (POST /api/album-suggestions/runs) — users who never clicked "generate" never received suggestions for newly imported photos. Theimport_completedvalue already existed in the V057 check constraint but nothing ever passed it.\n- Run creation goes exclusively throughAlbumSuggestionWorkflowService.generate(the controller's path), so the active-run guard, the partial unique index race protection, and the async executor are shared, not duplicated.\n- One SQL query per tick (no N+1), restricted to each user's firstmedia_owner_profilesrow to matchownerForUserowner resolution. The scheduled method never throws: per-tick and per-owner guards log and skip.\n\n## Configuration (defaults in code; env override via relaxed binding)\n-memories.album-suggestions.auto-trigger-enabled(defaulttrue;falseshort-circuits before any DB access)\n-memories.album-suggestions.auto-trigger-interval(default300000ms)\n-memories.album-suggestions.auto-trigger-debounce-minutes(default10)\n\n## Validation\n-rtk ./gradlew :apps:api:test --tests '*AlbumSuggestion*' --tests '*AutoTrigger*'→ BUILD SUCCESSFUL, 87 tests, 0 failures (7 new scheduler tests withClock.fixed: new-media→run created (incl. no-prior-run case), active queued/running run→no second run, debounce window→no run, disabled→no run, no-newer-media→no run, no-media owner→no run).\n\n## Notes\n- No existing file was modified — only the new scheduler + its test.\n- Pairs with the window-ordering fix (separate PR): auto-trigger alone would still produce runs whose candidate windows skip recent media while that fix is unmerged.