fix: count gap sources once for page and text

This commit is contained in:
Abdessamad Derraz committed 2026-11-22 00:58:05 +01:00
1 parent 5dbd2df9ec
commit 5e7593b3bf
5 files changed
+37 -30

No files matched your search

-17
View File
@@ -34,23 +34,6 @@ def _core_scope_note(config: dict, profiles: dict) -> str:
return f" (all libretro, plus {count_text(others, 'other core')})"
def gap_sources(data: dict) -> dict[str, int]:
"""Where each undeclared file of one emulator comes from.
A file the emulator's own package installs is not one to find. The
report's gap_missing counts it, and the gaps page announced 1,356 files
to source where 609 are, with a red badge on emulators that have none.
"""
counts = {"bios": 0, "data": 0, "large_file": 0, "bundled": 0, "missing": 0}
for gap in data.get("gap_details") or []:
source = gap.get("source", "")
if source == "missing" and gap.get("bundled"):
source = "bundled"
if source in counts:
counts[source] += 1
return counts
def _xref_upstream(profile: dict) -> str:
"""The project a core comes from: its upstream, else its own source."""
raw = profile.get("upstream") or profile.get("source", "")
+3 -3
View File
@@ -13,12 +13,12 @@ from core.text import series
from model.database import sha1_at
from model.platforms import native_layer
from model.profiles import is_emulator
from packs.crossref import gap_source_counts
from resolve.cores import resolve_platform_cores
from resolve.nativemode import check_label
from sitegen import markup, wanted as sitewanted
from sitegen.cards import PROVENANCE_LABELS, fetch_url
from sitegen.config import date_line
from sitegen.crossref import gap_sources
from sitegen.dataexports import build_emulator_gap_report
from sitegen.emulatorsindex import content_check_ceiling
from sitegen.parts import list_pages
@@ -667,7 +667,7 @@ def _undeclared_gaps(report_all: dict) -> tuple[dict[str, int], int, list[tuple[
if data["gaps"] == 0:
continue
total_undeclared += data["gaps"]
for key, count in gap_sources(data).items():
for key, count in gap_source_counts(data).items():
src_totals[key] += count
emulator_gaps.append((emu_name, data))
return src_totals, total_undeclared, emulator_gaps
@@ -678,7 +678,7 @@ def _complement_rows(emulator_gaps: list[tuple[str, dict]]) -> list[str]:
rows = []
for emu_name, data in sorted(emulator_gaps, key=lambda x: -x[1]["gaps"]):
display = data["emulator"]
sources = gap_sources(data)
sources = gap_source_counts(data)
to_source = sources["missing"]
missing_str = (
f'<span class="rb-badge rb-badge-danger">{to_source}</span>'