Files
sdb2-backend/app/api/v1/dashboard.py
JSC 6b55ff0e81 Refactor user endpoint tests to include pagination and response structure validation
- Updated tests for listing users to validate pagination and response format.
- Changed mock return values to include total count and pagination details.
- Refactored user creation mocks for clarity and consistency.
- Enhanced assertions to check for presence of pagination fields in responses.
- Adjusted test cases for user retrieval and updates to ensure proper handling of user data.
- Improved readability by restructuring mock definitions and assertions across various test files.
2025-08-17 12:36:52 +02:00

57 lines
1.8 KiB
Python

"""Dashboard API endpoints."""
from typing import Annotated, Any
from fastapi import APIRouter, Depends, Query
from app.core.dependencies import get_current_user, get_dashboard_service
from app.models.user import User
from app.services.dashboard import DashboardService
router = APIRouter(prefix="/dashboard", tags=["dashboard"])
@router.get("/soundboard-statistics")
async def get_soundboard_statistics(
_current_user: Annotated[User, Depends(get_current_user)],
dashboard_service: Annotated[DashboardService, Depends(get_dashboard_service)],
) -> dict[str, Any]:
"""Get soundboard statistics."""
return await dashboard_service.get_soundboard_statistics()
@router.get("/track-statistics")
async def get_track_statistics(
_current_user: Annotated[User, Depends(get_current_user)],
dashboard_service: Annotated[DashboardService, Depends(get_dashboard_service)],
) -> 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,
)