refactor(main): _ensure_fandom_tag stores bare names
Post-migration tag.name no longer embeds 'fandom:' prefix. Helper now creates/finds by (kind='fandom', name=bare). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+3
-4
@@ -26,15 +26,14 @@ def _parse_character_fandom(name_after_prefix):
|
|||||||
|
|
||||||
|
|
||||||
def _ensure_fandom_tag(fandom_name):
|
def _ensure_fandom_tag(fandom_name):
|
||||||
"""Find or create a fandom tag by name. Returns the Tag object.
|
"""Find or create a fandom tag by bare name. Returns the Tag object.
|
||||||
|
|
||||||
Normalizes the display name so callers don't have to remember.
|
Normalizes the display name so callers don't have to remember.
|
||||||
"""
|
"""
|
||||||
normalized = normalize_display_name(fandom_name.strip())
|
normalized = normalize_display_name(fandom_name.strip())
|
||||||
full_name = f"fandom:{normalized}"
|
fandom_tag = Tag.query.filter_by(kind='fandom', name=normalized).first()
|
||||||
fandom_tag = Tag.query.filter_by(name=full_name).first()
|
|
||||||
if not fandom_tag:
|
if not fandom_tag:
|
||||||
fandom_tag = Tag(name=full_name, kind="fandom")
|
fandom_tag = Tag(kind='fandom', name=normalized)
|
||||||
db.session.add(fandom_tag)
|
db.session.add(fandom_tag)
|
||||||
db.session.flush()
|
db.session.flush()
|
||||||
return fandom_tag
|
return fandom_tag
|
||||||
|
|||||||
Reference in New Issue
Block a user