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)), ); }