feat: Add endpoint and service method to retrieve top sounds by play count with filtering options
Some checks failed
Backend CI / lint (push) Failing after 4m54s
Backend CI / test (push) Failing after 4m24s

This commit is contained in:
JSC
2025-08-11 22:04:42 +02:00
parent 53b6c4bca5
commit c69a45c9b4
3 changed files with 151 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
from typing import Annotated, Any
from fastapi import APIRouter, Depends
from fastapi import APIRouter, Depends, Query
from app.core.dependencies import get_current_user, get_dashboard_service
from app.models.user import User
@@ -27,3 +27,19 @@ async def get_track_statistics(
) -> dict[str, Any]:
"""Get track statistics."""
return await dashboard_service.get_track_statistics()
@router.get("/top-sounds")
async def get_top_sounds(
_current_user: Annotated[User, Depends(get_current_user)],
dashboard_service: Annotated[DashboardService, Depends(get_dashboard_service)],
sound_type: Annotated[str, Query(description="Sound type filter (SDB, TTS, EXT, or 'all')")],
period: Annotated[str, Query(description="Time period (today, 1_day, 1_week, 1_month, 1_year, all_time)")] = "all_time",
limit: Annotated[int, Query(description="Number of top sounds to return", ge=1, le=100)] = 10,
) -> list[dict[str, Any]]:
"""Get top sounds by play count for a specific period."""
return await dashboard_service.get_top_sounds(
sound_type=sound_type,
period=period,
limit=limit
)