"""Dashboard service for statistics and analytics.""" from typing import Any from app.core.logging import get_logger from app.repositories.sound import SoundRepository logger = get_logger(__name__) class DashboardService: """Service for dashboard statistics and analytics.""" def __init__(self, sound_repository: SoundRepository) -> None: """Initialize the dashboard service.""" self.sound_repository = sound_repository async def get_soundboard_statistics(self) -> dict[str, Any]: """Get comprehensive soundboard statistics.""" try: stats = await self.sound_repository.get_soundboard_statistics() return { "sound_count": stats["count"], "total_play_count": stats["total_plays"], "total_duration": stats["total_duration"], "total_size": stats["total_size"], } except Exception: logger.exception("Failed to get soundboard statistics") raise async def get_track_statistics(self) -> dict[str, Any]: """Get comprehensive track statistics.""" try: stats = await self.sound_repository.get_track_statistics() return { "track_count": stats["count"], "total_play_count": stats["total_plays"], "total_duration": stats["total_duration"], "total_size": stats["total_size"], } except Exception: logger.exception("Failed to get track statistics") raise