mirror of
https://github.com/civitai/civitai.git
synced 2026-09-20 22:08:18 +08:00
6b58d1fa89
When Model.nsfw was true, every ModelVersion.nsfwLevel was stamped to nsfwBrowsingLevelsFlag (60 = R|X|XXX|Blocked). The old Model trigger only enqueued a Model-level UpdateNsfwLevel job on nsfw flip, so after a true->false flip the versions stayed at 60. updateModelNsfwLevels then bit_or'd the stale 60s back to 60 and the WHERE clause found no diff — model frozen, hidden from .com search. Trigger now enqueues a ModelVersion UpdateNsfwLevel job for every Published version under the model whenever Model.nsfw changes. The update-nsfw-levels cron processes versions before models in the same tick (see updateNsfwLevels batch order), so the rollup reads fresh version data. Also swapped the prior `!=` comparison to IS DISTINCT FROM for NULL-safety. Backfill: a hidden debug endpoint at src/pages/api/testing/backfill-stale-nsfw-rollups.ts (guarded by WEBHOOK_TOKEN) enqueues UpdateNsfwLevel jobs for the existing stuck cohort (~3,198 models / ~5,264 versions). Supports count, enqueue (with dryRun / limit / modelId), and verify actions. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>