diff --git a/app/celery_app.py b/app/celery_app.py index 164cbaf..c0624ca 100644 --- a/app/celery_app.py +++ b/app/celery_app.py @@ -71,7 +71,6 @@ def make_celery(app=None): 'app.tasks.scan.cleanup_old_tasks': {'queue': 'maintenance'}, 'app.tasks.scan.update_system_stats': {'queue': 'maintenance'}, 'app.tasks.scan.update_batch_stats': {'queue': 'maintenance'}, - 'app.tasks.maintenance.sync_character_fandoms': {'queue': 'maintenance'}, # Import tasks - handled by worker (heavy processing) 'app.tasks.import_file.*': {'queue': 'import'}, diff --git a/app/main.py b/app/main.py index 99aec47..336e4d9 100644 --- a/app/main.py +++ b/app/main.py @@ -612,13 +612,6 @@ def trigger_recompute_all_centroids(): return redirect(url_for('main.settings', tab='maintenance')) -@main.post('/settings/maintenance/sync-character-fandoms') -def trigger_sync_character_fandoms(): - from app.tasks.maintenance import sync_character_fandoms - sync_character_fandoms.apply_async(queue='maintenance') - return redirect(url_for('main.settings', tab='maintenance')) - - # ---------------------------- # Tag add/remove endpoints # ---------------------------- diff --git a/app/tasks/maintenance.py b/app/tasks/maintenance.py index a381d9f..fa6b484 100644 --- a/app/tasks/maintenance.py +++ b/app/tasks/maintenance.py @@ -1,66 +1,4 @@ -"""Maintenance-queue Celery tasks. Lightweight, user-triggered, non-ML.""" -import logging -from celery import shared_task -from sqlalchemy import text - -from app import db -from app.models import Tag - -log = logging.getLogger(__name__) - - -@shared_task( - name='app.tasks.maintenance.sync_character_fandoms', - soft_time_limit=120, - time_limit=180, -) -def sync_character_fandoms(): - """For every character tag with a non-null fandom_id, attach the fandom - tag to every image tagged with the character but not the fandom. - - Additive only — never removes fandom tags. - - Returns a summary dict with counts. - """ - chars = ( - Tag.query - .filter_by(kind='character') - .filter(Tag.fandom_id.isnot(None)) - .all() - ) - total_added = 0 - failed = 0 - for char in chars: - try: - result = db.session.execute( - text(""" - INSERT INTO image_tags (image_id, tag_id) - SELECT it.image_id, :fandom_id - FROM image_tags it - WHERE it.tag_id = :char_id - AND NOT EXISTS ( - SELECT 1 FROM image_tags it2 - WHERE it2.image_id = it.image_id - AND it2.tag_id = :fandom_id - ) - """), - {'char_id': char.id, 'fandom_id': char.fandom_id}, - ) - total_added += result.rowcount or 0 - db.session.commit() - except Exception as e: - db.session.rollback() - failed += 1 - log.warning( - "sync_character_fandoms: char tag %s (%s) failed: %s", - char.id, char.name, e, - ) - log.info( - "sync_character_fandoms: scanned %d characters, added %d image↔fandom links, %d failed", - len(chars), total_added, failed, - ) - return { - 'characters_scanned': len(chars), - 'links_added': total_added, - 'characters_failed': failed, - } +"""Maintenance-queue Celery tasks. Currently empty — the +sync_character_fandoms task was removed on 2026-04-21 as part of the +bare-name refactor (tag.fandom_id is now authoritative; no drift to sync). +""" diff --git a/app/templates/settings.html b/app/templates/settings.html index 15ff437..d1991dd 100644 --- a/app/templates/settings.html +++ b/app/templates/settings.html @@ -456,14 +456,6 @@ -
- Attach each character's fandom to every image already tagged with that character. - Additive only — existing fandom tags are never removed. Run after you've set a - fandom on an existing character, or whenever you suspect drift. -
-