feat(provenance): ArtistService resolves images via artist_id
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -47,18 +47,12 @@ class ArtistService:
|
||||
aid = artist.id
|
||||
|
||||
img_join = (
|
||||
select(ImageRecord.id)
|
||||
.join(ImageProvenance, ImageProvenance.image_record_id == ImageRecord.id)
|
||||
.join(Source, Source.id == ImageProvenance.source_id)
|
||||
.where(Source.artist_id == aid)
|
||||
select(ImageRecord.id).where(ImageRecord.artist_id == aid)
|
||||
)
|
||||
image_count = (
|
||||
await self.session.execute(
|
||||
select(func.count(func.distinct(ImageRecord.id)))
|
||||
.select_from(ImageRecord)
|
||||
.join(ImageProvenance, ImageProvenance.image_record_id == ImageRecord.id)
|
||||
.join(Source, Source.id == ImageProvenance.source_id)
|
||||
.where(Source.artist_id == aid)
|
||||
select(func.count(ImageRecord.id))
|
||||
.where(ImageRecord.artist_id == aid)
|
||||
)
|
||||
).scalar_one()
|
||||
|
||||
@@ -162,11 +156,7 @@ class ArtistService:
|
||||
# over ImageRecord fails in Postgres because its json columns have
|
||||
# no equality operator.
|
||||
stmt = select(ImageRecord).where(
|
||||
ImageRecord.id.in_(
|
||||
select(ImageProvenance.image_record_id)
|
||||
.join(Source, Source.id == ImageProvenance.source_id)
|
||||
.where(Source.artist_id == artist.id)
|
||||
)
|
||||
ImageRecord.artist_id == artist.id
|
||||
)
|
||||
if cursor:
|
||||
cur_ts, cur_id = decode_cursor(cursor)
|
||||
|
||||
Reference in New Issue
Block a user