feat: Enhance favorites functionality; add favorites filtering to playlists and sounds, and improve favorite indicators in responses
This commit is contained in:
@@ -8,7 +8,6 @@ from sqlmodel.ext.asyncio.session import AsyncSession
|
||||
from app.core.database import get_db, get_session_factory
|
||||
from app.core.dependencies import get_current_active_user_flexible
|
||||
from app.models.credit_action import CreditActionType
|
||||
from app.models.sound import Sound
|
||||
from app.models.user import User
|
||||
from app.repositories.sound import SortOrder, SoundRepository, SoundSortField
|
||||
from app.schemas.sound import SoundResponse, SoundsListResponse
|
||||
@@ -87,7 +86,7 @@ async def get_sounds( # noqa: PLR0913
|
||||
favorites_only=favorites_only,
|
||||
user_id=current_user.id,
|
||||
)
|
||||
|
||||
|
||||
# Add favorite indicators for each sound
|
||||
sound_responses = []
|
||||
for sound in sounds:
|
||||
@@ -95,7 +94,7 @@ async def get_sounds( # noqa: PLR0913
|
||||
favorite_count = await favorite_service.get_sound_favorite_count(sound.id)
|
||||
sound_response = SoundResponse.from_sound(sound, is_favorited, favorite_count)
|
||||
sound_responses.append(sound_response)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
|
||||
Reference in New Issue
Block a user