feat(tags): merge repoints image_tag and tag_suggestion_rejection with dedup

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-16 13:36:13 -04:00
parent e0a455466d
commit 003181ed41
2 changed files with 114 additions and 2 deletions
+37 -2
View File
@@ -327,10 +327,45 @@ class TagService:
)
async def _repoint_image_tags(self, src: int, tgt: int) -> int:
return 0
"""Drop source links whose image already links target, then move
the rest. Returns the number actually moved."""
await self.session.execute(
image_tag.delete().where(
and_(
image_tag.c.tag_id == src,
image_tag.c.image_record_id.in_(
select(image_tag.c.image_record_id).where(
image_tag.c.tag_id == tgt
)
),
)
)
)
res = await self.session.execute(
image_tag.update()
.where(image_tag.c.tag_id == src)
.values(tag_id=tgt)
)
return res.rowcount or 0
async def _repoint_rejections(self, src: int, tgt: int) -> None:
pass
from ..models.tag_suggestion_rejection import TagSuggestionRejection
await self.session.execute(
text(
"DELETE FROM tag_suggestion_rejection r "
"WHERE r.tag_id = :src AND EXISTS ("
" SELECT 1 FROM tag_suggestion_rejection r2 "
" WHERE r2.tag_id = :tgt "
" AND r2.image_record_id = r.image_record_id)"
),
{"src": src, "tgt": tgt},
)
await self.session.execute(
update(TagSuggestionRejection)
.where(TagSuggestionRejection.tag_id == src)
.values(tag_id=tgt)
)
async def _repoint_allowlist(self, src: int, tgt: int) -> None:
pass