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:
+10
@@ -655,6 +655,16 @@ def trigger_sync_character_fandoms_to_images():
|
||||
return redirect(url_for('main.settings', tab='maintenance'))
|
||||
|
||||
|
||||
@main.post('/settings/maintenance/apply-auto-accept-predictions')
|
||||
def trigger_apply_auto_accept_predictions():
|
||||
"""Sweep every image, apply general WD14 predictions above the auto-accept
|
||||
threshold without requiring the user to open each modal. One-shot —
|
||||
intended to be run after a backfill drains."""
|
||||
from app.tasks.maintenance import apply_auto_accept_predictions
|
||||
apply_auto_accept_predictions.apply_async(queue='maintenance')
|
||||
return redirect(url_for('main.settings', tab='maintenance'))
|
||||
|
||||
|
||||
@main.post('/settings/maintenance/verify-images')
|
||||
def trigger_verify_unverified_images():
|
||||
"""Sweep ImageRecords and enqueue per-image structural verification.
|
||||
|
||||
Reference in New Issue
Block a user