import { session } from '$lib/stores/session.svelte'; import { apiRequest, type RequestOptions } from './client'; import type { MatchStatsDTO } from './schema-helpers'; /** StatisticsController is `[Authorize]`, like the tournament endpoints. */ function authed(options: RequestOptions): RequestOptions { return { ...options, token: options.token ?? session.token }; } /** * POST /api/Statistics/Matches — set-level statistics (win/loss, games, head to * head) for the given events, read from the `set` rows an import persisted. * * Unlike `GetResults` this takes every event in one call: the service tolerates * brackets with no set rows instead of throwing, and reports what it could see in * `coverage`. Always show that coverage — many older brackets were imported * without sets, so a low `bracketsWithSets` means these numbers describe only a * slice of the scope. */ export function getMatchStats( eventIds: number[], options: RequestOptions = {} ): Promise { return apiRequest('/api/Statistics/Matches', { ...authed(options), method: 'POST', body: eventIds }); }