"""Calcule et exporte les statistiques principales sur les sets LEGO filtrés."""

from pathlib import Path

from lib.rebrickable.stats import compute_basic_stats, read_rows, write_stats_csv


THEMES_PATH = Path("data/raw/themes.csv")
ALL_SETS_PATH = Path("data/raw/sets.csv")
FILTERED_SETS_PATH = Path("data/intermediate/sets_filtered.csv")
ENRICHED_SETS_PATH = Path("data/intermediate/sets_enriched.csv")
DESTINATION_PATH = Path("data/final/stats.csv")


def main() -> None:
    """Charge les données, calcule les statistiques et exporte le CSV."""
    themes = read_rows(THEMES_PATH)
    all_sets = read_rows(ALL_SETS_PATH)
    filtered_sets = read_rows(FILTERED_SETS_PATH)
    enriched_sets = read_rows(ENRICHED_SETS_PATH)
    stats = compute_basic_stats(themes, all_sets, filtered_sets, enriched_sets)
    write_stats_csv(DESTINATION_PATH, stats)


if __name__ == "__main__":
    main()
