Read the official standings and results from the CSI portal.
The Campionato page showed hardcoded demo data. It now reads the real 2025/26 season (Campionato Open Misto Eccellenza, project 767, team 3359, Girone B) from the Livescore CSI Bologna portal. The portal has no documented API: we call the same endpoints its own pages call over ajax, so parsing must degrade gracefully. A single server route fetches them, caches for 6 hours and serves the last good payload on failure; the page falls back to the previous data when nothing is available. No browser ever contacts the portal, keeping the request count independent of how many players open the app. Also fixes the header, which claimed "Girone C - CSI Milano". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import type { DatiCsi } from "./csi-core";
|
||||
|
||||
export const CSI_KEY = ["csi"] as const;
|
||||
|
||||
/**
|
||||
* Classifica e risultati ufficiali CSI. Il server tiene una cache di 6 ore:
|
||||
* qui basta una lettura per sessione.
|
||||
*/
|
||||
export function useCsi() {
|
||||
return useQuery<DatiCsi>({
|
||||
queryKey: CSI_KEY,
|
||||
queryFn: async () => {
|
||||
const res = await fetch("/api/public/csi");
|
||||
if (!res.ok) throw new Error("CSI non disponibile");
|
||||
return res.json();
|
||||
},
|
||||
staleTime: 6 * 60 * 60_000,
|
||||
retry: 1,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user