"""Trace le nombre de minifigs par set filtré."""

from pathlib import Path

from lib.plots.minifig_counts import plot_minifigs_per_set
from lib.rebrickable.minifig_counts import build_minifig_counts_by_set, write_minifig_counts


SETS_PATH = Path("data/intermediate/sets_enriched.csv")
PARTS_FILTERED_PATH = Path("data/intermediate/parts_filtered.csv")
PARTS_CATALOG_PATH = Path("data/raw/parts.csv")
COUNTS_PATH = Path("data/intermediate/minifig_counts_by_set.csv")
DESTINATION_PATH = Path("figures/step21/minifigs_per_set.png")


def main() -> None:
    """Construit le CSV de comptage des minifigs et trace le graphique associé."""
    counts = build_minifig_counts_by_set(SETS_PATH, PARTS_FILTERED_PATH, PARTS_CATALOG_PATH)
    write_minifig_counts(COUNTS_PATH, counts)
    plot_minifigs_per_set(COUNTS_PATH, DESTINATION_PATH)


if __name__ == "__main__":
    main()
