Files
romm/backend/endpoints/stats.py
cc 778097f4a0 feat: add per-platform metadata coverage and region breakdown to server stats
Enhances the server stats page with two new per-platform statistics:
- Metadata coverage: shows which sources matched ROMs (ordered by user's scan priority config)
- Region breakdown: shows ROM counts per region with flag emojis

Backend adds two new efficient queries (single GROUP BY for metadata, Python-side aggregation for regions).
Frontend redesigns platform cards with a tabular detail layout, size bar visualization, and expandable region chips.

> This PR was developed with AI assistance (Claude Code) per CONTRIBUTING.md disclosure requirements.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 22:15:08 -04:00

29 lines
896 B
Python

from endpoints.responses.stats import StatsReturn
from handler.database import db_stats_handler
from utils.router import APIRouter
router = APIRouter(
prefix="/stats",
tags=["stats"],
)
@router.get("")
def stats() -> StatsReturn:
"""Endpoint to return the current RomM stats
Returns:
dict: Dictionary with all the stats
"""
return {
"PLATFORMS": db_stats_handler.get_platforms_count(),
"ROMS": db_stats_handler.get_roms_count(),
"SAVES": db_stats_handler.get_saves_count(),
"STATES": db_stats_handler.get_states_count(),
"SCREENSHOTS": db_stats_handler.get_screenshots_count(),
"TOTAL_FILESIZE_BYTES": db_stats_handler.get_total_filesize(),
"METADATA_COVERAGE": db_stats_handler.get_metadata_coverage_by_platform(),
"REGION_BREAKDOWN": db_stats_handler.get_region_breakdown_by_platform(),
}