BUILD147 — обновление турнирной таблицы

This commit is contained in:
2026-09-18 18:46:36 +03:00
parent baca1e083c
commit a25c633a0b
4 changed files with 86 additions and 11 deletions

View File

@@ -1262,11 +1262,11 @@
}));
}
function standingsUrl({ sync = false } = {}) {
function standingsUrl({ sync = false, force = false } = {}) {
const params = new URLSearchParams({ language: state.language });
if (state.selectedGameId) params.set("game_id", state.selectedGameId);
return `/api/hockey/tournaments/${encodeURIComponent(state.selectedId)}/standings`
+ `${sync ? "/sync" : ""}?${params.toString()}`;
const suffix = force ? "/force-sync" : (sync ? "/sync" : "");
return `/api/hockey/tournaments/${encodeURIComponent(state.selectedId)}/standings${suffix}?${params.toString()}`;
}
function applyStandingsData() {
@@ -1275,26 +1275,37 @@
});
}
async function loadTournamentStandings({ sync = false } = {}) {
if (!state.selectedId) return;
async function loadTournamentStandings({ sync = false, force = false } = {}) {
if (!state.selectedId) return null;
try {
const shouldPost = Boolean(sync || force);
const loaded = await request(
standingsUrl({ sync }),
sync ? { method: "POST", timeoutMs: 30000 } : {}
standingsUrl({ sync, force }),
shouldPost ? { method: "POST", timeoutMs: 30000 } : {}
);
state.standings = loaded.standings || loaded;
applyStandingsData();
return loaded;
} catch (error) {
if (sync) {
if (sync || force) {
try {
const cached = await request(standingsUrl({ sync: false }));
const cached = await request(standingsUrl({ sync: false, force: false }));
state.standings = cached.standings || cached;
applyStandingsData();
} catch (_) {}
}
if (force) throw error;
return null;
}
}
async function refreshTournamentStandings() {
if (!state.selectedId) {
throw new Error(state.language === "en" ? "Tournament is not selected" : "Турнир не выбран");
}
return loadTournamentStandings({ sync: true, force: true });
}
function tournamentStatisticsUrl({ sync = false, force = false } = {}) {
const params = new URLSearchParams({ language: state.language });
if (force) params.set("force", "true");
@@ -2699,6 +2710,7 @@ document.addEventListener("visibilitychange", () => {
selectTournament: openTournament,
selectGame: openGame,
reloadGames: () => loadGames({ autoSync: false }),
refreshStandings: refreshTournamentStandings,
};
function installGlobalTooltipPortal() {