refactor: Update playlist service and endpoints for global current playlist management

This commit is contained in:
JSC
2025-08-01 16:58:25 +02:00
parent 3132175354
commit c0f51b2e23
4 changed files with 63 additions and 30 deletions

View File

@@ -66,6 +66,18 @@ class PlaylistRepository(BaseRepository[Playlist]):
logger.exception("Failed to get current playlist for user: %s", user_id)
raise
async def get_global_current_playlist(self) -> Playlist | None:
"""Get the global current playlist (app-wide)."""
try:
statement = select(Playlist).where(
Playlist.is_current == True, # noqa: E712
)
result = await self.session.exec(statement)
return result.first()
except Exception:
logger.exception("Failed to get global current playlist")
raise
async def search_by_name(
self, query: str, user_id: int | None = None,
) -> list[Playlist]: