feat(explore): exclude WIP-tagged work from the Explore rabbit-hole
Explore's neighbour grid (/api/gallery/similar → gallery_service.similar) now takes an Explore-only exclude_wip flag that drops `wip` system-tagged images from the candidates, alongside the banner/editor presentation tags. The gallery's own "similar" button is unchanged (keeps wip, #1274) — only the Explore store passes exclude_wip=1. The anchor itself may still be a WIP; only neighbours are filtered. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -98,6 +98,30 @@ async def test_similar_excludes_presentation_tagged_images(db):
|
||||
assert {i.id for i in res_from_banner} == {src.id, wipped.id, plain.id}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_similar_exclude_wip_drops_wip_neighbors(db):
|
||||
"""Explore passes exclude_wip=True to also hide work-in-progress from the
|
||||
rabbit-hole (banner is always hidden; wip only when asked)."""
|
||||
src = await _img(db, 1, _vec(1, 0))
|
||||
bannered = await _img(db, 2, _vec(1, 0.02)) # always hidden
|
||||
wipped = await _img(db, 3, _vec(1, 0.3)) # hidden only with exclude_wip
|
||||
plain = await _img(db, 4, _vec(1, 0.6))
|
||||
banner_tag = (await db.execute(select(Tag).where(
|
||||
Tag.is_system.is_(True), Tag.name == "banner"))).scalar_one()
|
||||
wip_tag = (await db.execute(select(Tag).where(
|
||||
Tag.is_system.is_(True), Tag.name == "wip"))).scalar_one()
|
||||
await db.execute(image_tag.insert().values(
|
||||
image_record_id=bannered.id, tag_id=banner_tag.id, source="manual"))
|
||||
await db.execute(image_tag.insert().values(
|
||||
image_record_id=wipped.id, tag_id=wip_tag.id, source="manual"))
|
||||
svc = GalleryService(db)
|
||||
res = await svc.similar(src.id, limit=10, exclude_wip=True)
|
||||
assert [i.id for i in res] == [plain.id] # wip + banner both gone
|
||||
# Default (gallery "similar" button) still keeps wip (#1274).
|
||||
res_default = await svc.similar(src.id, limit=10)
|
||||
assert wipped.id in {i.id for i in res_default}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_similar_composes_with_tag_filter(db):
|
||||
src = await _img(db, 1, _vec(1, 0))
|
||||
|
||||
Reference in New Issue
Block a user