+19
-19
backend/src/backend/api/artists.py
+19
-19
backend/src/backend/api/artists.py
···
205
205
return ArtistResponse.model_validate(artist)
206
206
207
207
208
+
@router.post("/batch")
209
+
async def get_artists_batch(
210
+
dids: list[str],
211
+
db: Annotated[AsyncSession, Depends(get_db)],
212
+
) -> dict[str, ArtistResponse]:
213
+
"""get artist profiles for multiple DIDs (public endpoint).
214
+
215
+
returns a dict mapping DID -> artist data for any DIDs that exist in our database.
216
+
DIDs not found are simply omitted from the response.
217
+
"""
218
+
if not dids:
219
+
return {}
220
+
221
+
result = await db.execute(select(Artist).where(Artist.did.in_(dids)))
222
+
artists = result.scalars().all()
223
+
224
+
return {artist.did: ArtistResponse.model_validate(artist) for artist in artists}
225
+
226
+
208
227
@router.get("/by-handle/{handle}")
209
228
async def get_artist_profile_by_handle(
210
229
handle: str, db: Annotated[AsyncSession, Depends(get_db)]
···
247
266
response.show_liked_on_profile = prefs.show_liked_on_profile if prefs else False
248
267
response.support_url = prefs.support_url if prefs else None
249
268
return response
250
-
251
-
252
-
@router.post("/batch")
253
-
async def get_artists_batch(
254
-
dids: list[str],
255
-
db: Annotated[AsyncSession, Depends(get_db)],
256
-
) -> dict[str, ArtistResponse]:
257
-
"""get artist profiles for multiple DIDs (public endpoint).
258
-
259
-
returns a dict mapping DID -> artist data for any DIDs that exist in our database.
260
-
DIDs not found are simply omitted from the response.
261
-
"""
262
-
if not dids:
263
-
return {}
264
-
265
-
result = await db.execute(select(Artist).where(Artist.did.in_(dids)))
266
-
artists = result.scalars().all()
267
-
268
-
return {artist.did: ArtistResponse.model_validate(artist) for artist in artists}
269
269
270
270
271
271
@router.get("/{artist_did}/analytics")