1

Limite la timeline minifigs/set à 2025

This commit is contained in:
Richard Dern 2025-12-02 14:30:29 +01:00
parent c9f1acee4b
commit 1dd713db4a
2 changed files with 13 additions and 4 deletions

View File

@ -87,11 +87,14 @@ def build_minifigs_per_year(
inventory_minifigs_path: Path,
) -> List[dict]:
"""Calcule le nombre moyen de minifigs par set et par année (filtré vs catalogue)."""
max_year = 2025
filtered_totals: Dict[int, Dict[str, int]] = {}
with filtered_counts_path.open() as csv_file:
reader = csv.DictReader(csv_file)
for row in reader:
year = int(row["year"])
if year > max_year:
continue
current = filtered_totals.get(year)
if current is None:
filtered_totals[year] = {"minifigs": int(row["minifig_count"]), "sets": 1}
@ -104,6 +107,8 @@ def build_minifigs_per_year(
reader = csv.DictReader(csv_file)
for row in reader:
year = int(row["year"])
if year > max_year:
continue
current = catalog_totals.get(year)
if current is None:
catalog_totals[year] = {"minifigs": global_minifigs.get(row["set_num"], 0), "sets": 1}

View File

@ -78,7 +78,8 @@ def test_build_minifigs_per_year_computes_averages(tmp_path: Path) -> None:
"set_num,set_id,name,year,minifig_count\n"
"123-1,123,Set A,2020,2\n"
"124-1,124,Set B,2020,1\n"
"125-1,125,Set C,2021,3\n",
"125-1,125,Set C,2021,3\n"
"126-1,126,Set D,2026,4\n",
)
all_sets_path = tmp_path / "sets.csv"
write_csv(
@ -87,7 +88,8 @@ def test_build_minifigs_per_year_computes_averages(tmp_path: Path) -> None:
"123-1,Set A,2020,1,300\n"
"124-1,Set B,2020,1,150\n"
"125-1,Set C,2021,1,100\n"
"200-1,Set D,2020,1,50\n",
"200-1,Set D,2020,1,50\n"
"126-1,Set D,2026,1,80\n",
)
inventories_path = tmp_path / "inventories.csv"
write_csv(
@ -96,7 +98,8 @@ def test_build_minifigs_per_year_computes_averages(tmp_path: Path) -> None:
"10,1,123-1\n"
"20,1,124-1\n"
"30,1,125-1\n"
"40,1,200-1\n",
"40,1,200-1\n"
"50,1,126-1\n",
)
inventory_minifigs_path = tmp_path / "inventory_minifigs.csv"
write_csv(
@ -105,7 +108,8 @@ def test_build_minifigs_per_year_computes_averages(tmp_path: Path) -> None:
"10,fig-a,2\n"
"20,fig-b,1\n"
"30,fig-c,3\n"
"40,fig-d,4\n",
"40,fig-d,4\n"
"50,fig-e,5\n",
)
rows = build_minifigs_per_year(