feat(maintenance): library-wide apply of auto-accept predictions

Adds a Celery task + Settings button that walks every image and applies
general-category WD14 predictions at or above the auto-accept threshold,
without needing the user to open each modal. Same side effects as the
modal's per-image auto-accept flow (creates kind='user' tag if needed,
attaches to image, writes SuggestionFeedback decision='accepted').

Lazy-imports app.services.tag_suggestions so the maintenance worker
doesn't pay its overhead unless this task fires. Amortizes _config()
and _existing_tag_names() across the loop. Commits per-batch (100
images) to keep transactions short and let later batches see freshly
created Tag rows.

Skips integrity-flagged images (get_suggestions already returns empty
for those). Idempotent — re-running just no-ops on already-applied
images via the existing 'tag not in img.tags' guard.

Trigger: Settings -> Maintenance -> "Apply auto-accepts library-wide"
(confirm-gated since it walks the entire library).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-26 13:45:34 -04:00
parent 641a52d1ad
commit 6488dfff1a
4 changed files with 130 additions and 1 deletions
+1
View File
@@ -75,6 +75,7 @@ def make_celery(app=None):
'app.tasks.maintenance.sync_character_fandoms_to_images': {'queue': 'maintenance'},
'app.tasks.maintenance.verify_media_integrity': {'queue': 'maintenance'},
'app.tasks.maintenance.verify_unverified_images': {'queue': 'maintenance'},
'app.tasks.maintenance.apply_auto_accept_predictions': {'queue': 'maintenance'},
# Import tasks - handled by worker (heavy processing)
'app.tasks.import_file.*': {'queue': 'import'},