From 41ed3a1f0fda7be0c7c768eff4a8b7710f60e565 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Sun, 6 Sep 2026 10:29:34 +0200 Subject: [PATCH] =?UTF-8?q?Conta=20le=20presenze=20solo=20sugli=20eventi?= =?UTF-8?q?=20gi=C3=A0=20passati,=20non=20su=20quelli=20odierni=20o=20futu?= =?UTF-8?q?ri.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5 --- src/lib/presenze.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/presenze.ts b/src/lib/presenze.ts index 75d0db0..d1180ca 100644 --- a/src/lib/presenze.ts +++ b/src/lib/presenze.ts @@ -3,6 +3,7 @@ import { supabase } from "@/integrations/supabase/client"; import type { Stato } from "./crapp-data"; import type { Evento } from "./eventi"; import { aggiornaSerie } from "./serie"; +import { dataOggi } from "./scout-live"; export const PRESENZE_KEY = ["risposte-presenze"] as const; @@ -12,11 +13,13 @@ export type MappaPresenze = Record>; /** eventoId -> giocatoreId -> istante della prima risposta (ISO). */ export type MappaTempiRisposta = Record>; -/** Allenamenti e partite CrAPP che contano per le statistiche di presenza. */ +/** Allenamenti e partite CrAPP giĆ  passati, che contano per le statistiche di presenza. */ function eventiContanoPresenze(eventi: Evento[], giocatoreId?: string) { + const oggi = dataOggi(); return eventi.filter( (e) => (e.tipo === "partita" || e.tipo === "allenamento") && + e.data < oggi && (giocatoreId === undefined || e.convocati.length === 0 || e.convocati.includes(giocatoreId)), ); }