Refactor sound and extraction services to include user and timestamp fields
- Updated ExtractionInfo to include user_id, created_at, and updated_at fields. - Modified ExtractionService to return user and timestamp information in extraction responses. - Enhanced sound serialization in PlayerState to include extraction URL if available. - Adjusted PlaylistRepository to load sound extractions when retrieving playlist sounds. - Added tests for new fields in extraction and sound endpoints, ensuring proper response structure. - Created new test file endpoints for sound downloads and thumbnail retrievals, including success and error cases. - Refactored various test cases for consistency and clarity, ensuring proper mocking and assertions.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Playlist repository for database operations."""
|
||||
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy.orm import selectinload
|
||||
from sqlmodel import select
|
||||
from sqlmodel.ext.asyncio.session import AsyncSession
|
||||
|
||||
@@ -84,11 +85,12 @@ class PlaylistRepository(BaseRepository[Playlist]):
|
||||
raise
|
||||
|
||||
async def get_playlist_sounds(self, playlist_id: int) -> list[Sound]:
|
||||
"""Get all sounds in a playlist, ordered by position."""
|
||||
"""Get all sounds in a playlist with extractions, ordered by position."""
|
||||
try:
|
||||
statement = (
|
||||
select(Sound)
|
||||
.join(PlaylistSound)
|
||||
.options(selectinload(Sound.extractions))
|
||||
.where(PlaylistSound.playlist_id == playlist_id)
|
||||
.order_by(PlaylistSound.position)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user