Implémente système multi-utilisateurs avec classement

- Auth cookie simple (SSO-ready) : login/logout, redirection si non authentifié
- Données isolées par utilisateur dans /data/users/{user_id}/
- Migration automatique des données legacy au premier login
- Page classement avec podium et tableau comparatif (score, précision zéro, conformité)
- Nav mise à jour : Classement, affichage utilisateur courant, déconnexion

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
toto
2026-06-24 17:29:07 +02:00
parent 1a34bff1c6
commit b6e0fcd925
7 changed files with 673 additions and 131 deletions

View File

@ -50,9 +50,9 @@ def _compliance_over(all_days: list[tuple], cg_set: set) -> dict:
return {"pct": round(100 * n_ok / n) if n else None, "n": n, "n_ok": n_ok}
def compute_all_stats() -> dict:
all_weeks = sorted(list_all_weeks())
conges = load_conges()
def compute_all_stats(user_id: str = "") -> dict:
all_weeks = sorted(list_all_weeks(user_id))
conges = load_conges(user_id)
h_jour = int(float(load_config().get("heures_jour", 7.8)) * 60)
cg_set = {(c["date"], c["type"]) for c in conges}
@ -63,7 +63,6 @@ def compute_all_stats() -> dict:
current_ym = (today.year, today.month)
SLOTS = ["matin_entree", "matin_sortie", "aprem_entree", "aprem_sortie"]
# Store (value, date) pairs per slot
slot_pairs: dict[str, list[tuple[int, str]]] = {s: [] for s in SLOTS}
comp_n = {s: 0 for s in SLOTS}
comp_ok = {s: 0 for s in SLOTS}
@ -81,7 +80,7 @@ def compute_all_stats() -> dict:
prev_week_day_list: list[tuple] = []
for year, week in all_weeks:
raw = load_week_pointages(year, week)
raw = load_week_pointages(year, week, user_id)
if not raw:
continue
@ -136,7 +135,7 @@ def compute_all_stats() -> dict:
weekly_balances.append({
"year": year, "week": week,
"label": f"S{week:02d}",
"date": dates[0], # Monday — used for period filtering
"date": dates[0],
"delta_min": week_delta,
"delta": minutes_to_hhmm(week_delta),
"partial": week_has_incomplete,
@ -163,7 +162,6 @@ def compute_all_stats() -> dict:
for slot in comp_n
}
rates = [v for v in compliance.values() if v is not None]
overall_slot = round(sum(rates) / len(rates)) if rates else None
n_jours = max(len(slot_pairs["matin_entree"]), len(slot_pairs["aprem_entree"]))
deltas = [b["delta_min"] for b in weekly_balances]
@ -176,7 +174,6 @@ def compute_all_stats() -> dict:
return {
"time_stats": time_stats,
"compliance": compliance,
"overall_compliance": overall_slot,
"weekly_balances": weekly_balances,
"total_weeks": len(weekly_balances),
"n_jours": n_jours,