feat: connect tournament views to APIs and recover archived stats
Remove development previews and complete hall of fame, match history, official results, and multi-kill API integration. Fix active match pagination and team-ready controls, preserve basic scoreboards, and recover statistics when Riot archives arrive. Use bounded in-process cache invalidation retries and add the Riot match lookup index migration with regression coverage.
This commit is contained in:
1 parent
20e1e6ec04
commit
0d7617e2d2
70 files changed
+3739
-1793
No files matched your search
@@ -5,9 +5,11 @@ import type {
|
||||
CompetitionCommandResponse,
|
||||
CompetitionDetailResponse,
|
||||
CreateSeriesAdjudicationRequest,
|
||||
HallOfFameResponse,
|
||||
MatchDetailResponse,
|
||||
MatchEventType,
|
||||
MatchLifecycleStatus,
|
||||
MatchListView,
|
||||
MatchListResponse,
|
||||
ReverseSeriesResultRequest,
|
||||
SeriesId,
|
||||
@@ -33,6 +35,7 @@ import type {
|
||||
ApiCommunity,
|
||||
ApiCommunityUserSearchCandidate,
|
||||
ApiEnqueueRefreshResult,
|
||||
ApiHistorySeason,
|
||||
ApiInternalMatchDetailResponse,
|
||||
ApiInternalMatchListResponse,
|
||||
ApiLeaderboardResponse,
|
||||
@@ -72,6 +75,8 @@ interface MatchesQueryOptions {
|
||||
scheduledFrom?: string;
|
||||
scheduledTo?: string;
|
||||
sort?: 'asc' | 'desc';
|
||||
view?: MatchListView;
|
||||
asOf?: string;
|
||||
}
|
||||
|
||||
interface MatchesPageQueryOptions extends MatchesQueryOptions {
|
||||
@@ -91,6 +96,9 @@ export interface CommunityInternalStatsFilters {
|
||||
to?: string;
|
||||
championId?: number;
|
||||
limit?: number;
|
||||
query?: string;
|
||||
format?: 'pair' | 'tournament';
|
||||
playerId?: string;
|
||||
}
|
||||
|
||||
function createMatchesPath(
|
||||
@@ -108,6 +116,8 @@ function createMatchesPath(
|
||||
if (options.scheduledTo) searchParams.set('scheduledTo', options.scheduledTo);
|
||||
if (options.sort) searchParams.set('sort', options.sort);
|
||||
if (options.includeResults) searchParams.set('includeResults', 'true');
|
||||
if (options.view) searchParams.set('view', options.view);
|
||||
if (options.asOf) searchParams.set('asOf', options.asOf);
|
||||
|
||||
const queryString = searchParams.toString();
|
||||
return `/communities/${communityId}/matches${queryString ? `?${queryString}` : ''}`;
|
||||
@@ -161,6 +171,17 @@ export function useCommunity(communityId = DEFAULT_COMMUNITY_ID) {
|
||||
});
|
||||
}
|
||||
|
||||
export function useHallOfFame(communityId = DEFAULT_COMMUNITY_ID) {
|
||||
return useQuery({
|
||||
queryKey: ['hall-of-fame', communityId],
|
||||
queryFn: () => apiFetch<HallOfFameResponse>(
|
||||
`/communities/${communityId}/matches/hall-of-fame`,
|
||||
{ auth: 'none' },
|
||||
),
|
||||
enabled: Boolean(communityId),
|
||||
});
|
||||
}
|
||||
|
||||
export function useMatches(
|
||||
options: MatchesQueryOptions,
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
@@ -180,6 +201,8 @@ export function useMatches(
|
||||
options.scheduledTo ?? null,
|
||||
options.sort ?? null,
|
||||
options.eventType ?? null,
|
||||
options.view ?? null,
|
||||
options.asOf ?? null,
|
||||
],
|
||||
queryFn: async () => {
|
||||
const response = await authScope.fetch<MatchListResponse>(
|
||||
@@ -211,6 +234,8 @@ export function useMatchesPage(
|
||||
options.sort ?? null,
|
||||
options.includeResults ?? false,
|
||||
options.eventType ?? null,
|
||||
options.view ?? null,
|
||||
options.asOf ?? null,
|
||||
],
|
||||
queryFn: () =>
|
||||
authScope.fetch<MatchListResponse>(
|
||||
@@ -676,6 +701,9 @@ function createCommunityInternalStatsPath(
|
||||
if (filters.championId)
|
||||
searchParams.set('championId', String(filters.championId));
|
||||
if (filters.limit) searchParams.set('limit', String(filters.limit));
|
||||
if (filters.query) searchParams.set('q', filters.query);
|
||||
if (filters.format) searchParams.set('format', filters.format);
|
||||
if (filters.playerId) searchParams.set('playerId', filters.playerId);
|
||||
for (const [key, value] of Object.entries(extra)) {
|
||||
if (value !== null && value !== undefined && value !== '') {
|
||||
searchParams.set(key, String(value));
|
||||
@@ -700,16 +728,22 @@ export function useCommunityInternalStatsMatches(
|
||||
filters.to ?? null,
|
||||
filters.championId ?? null,
|
||||
filters.limit ?? null,
|
||||
filters.query ?? null,
|
||||
filters.format ?? null,
|
||||
filters.playerId ?? null,
|
||||
],
|
||||
queryFn: ({ pageParam }) =>
|
||||
apiFetch<ApiInternalMatchListResponse>(
|
||||
createCommunityInternalStatsPath(communityId, 'matches', filters, {
|
||||
cursor: pageParam,
|
||||
cursor: pageParam?.cursor,
|
||||
cursorMatchId: pageParam?.matchId,
|
||||
}),
|
||||
{ auth: 'none' },
|
||||
),
|
||||
initialPageParam: null as number | null,
|
||||
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
||||
initialPageParam: null as { cursor: number; matchId?: string } | null,
|
||||
getNextPageParam: (lastPage) => lastPage.nextCursor === null
|
||||
? null
|
||||
: { cursor: lastPage.nextCursor, matchId: lastPage.nextCursorMatchId },
|
||||
enabled: Boolean(communityId && enabled),
|
||||
});
|
||||
}
|
||||
@@ -727,6 +761,7 @@ export function useCommunityLeaderboard(
|
||||
filters.from ?? null,
|
||||
filters.to ?? null,
|
||||
filters.championId ?? null,
|
||||
filters.query ?? null,
|
||||
],
|
||||
queryFn: () =>
|
||||
apiFetch<ApiLeaderboardResponse>(
|
||||
@@ -739,6 +774,17 @@ export function useCommunityLeaderboard(
|
||||
});
|
||||
}
|
||||
|
||||
export function useCommunityStatsSeasons(communityId = DEFAULT_COMMUNITY_ID) {
|
||||
return useQuery({
|
||||
queryKey: ['community-stats-seasons', communityId],
|
||||
queryFn: () => apiFetch<{ seasons: ApiHistorySeason[] }>(
|
||||
`/communities/${communityId}/internal-stats/seasons`,
|
||||
{ auth: 'none' },
|
||||
),
|
||||
enabled: Boolean(communityId),
|
||||
});
|
||||
}
|
||||
|
||||
export function useTeamInsights(
|
||||
filters: CommunityInternalStatsFilters,
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import type {
|
||||
GrandFinalGameCount,
|
||||
GameAnalysisAvailability,
|
||||
GameId,
|
||||
GameSlotId,
|
||||
InternalMatchCompetition,
|
||||
InternalMatchResultPresentation,
|
||||
SeriesId,
|
||||
MatchEventType,
|
||||
RecentMatchParticipantRank,
|
||||
MatchGameMode,
|
||||
MatchPosition,
|
||||
MatchPositionPreferenceView,
|
||||
@@ -530,6 +537,7 @@ export interface ApiRecentMatchTeamParticipant {
|
||||
championId: number;
|
||||
championLevel: number;
|
||||
teamPosition: string;
|
||||
tier?: RecentMatchParticipantRank;
|
||||
kills: number;
|
||||
deaths: number;
|
||||
assists: number;
|
||||
@@ -588,7 +596,7 @@ export interface ApiRecentMatchView {
|
||||
summonerSpells: [number, number];
|
||||
perks: ApiRunePerks;
|
||||
teams: ApiRecentMatchTeam[];
|
||||
/** 최대 연속 처치 수. API가 아직 내려주지 않아 화면은 없을 때를 견딘다. */
|
||||
/** 경기에서 기록한 최대 연속 처치 수. */
|
||||
largestMultiKill?: number;
|
||||
}
|
||||
|
||||
@@ -606,6 +614,7 @@ export interface ApiInternalMatchCard {
|
||||
status: 'finished' | 'in-progress';
|
||||
gameCount: number;
|
||||
winnerTeamIndex?: number;
|
||||
resultPresentation?: InternalMatchResultPresentation;
|
||||
seriesResults: Array<{
|
||||
teamAIndex: number;
|
||||
teamBIndex: number;
|
||||
@@ -636,6 +645,7 @@ export interface ApiInternalMatchCard {
|
||||
export interface ApiInternalMatchListResponse {
|
||||
matches: ApiInternalMatchCard[];
|
||||
nextCursor: number | null;
|
||||
nextCursorMatchId?: string;
|
||||
season: ApiHistorySeason;
|
||||
}
|
||||
|
||||
@@ -663,6 +673,7 @@ export interface ApiLeaderboardRow {
|
||||
export interface ApiLeaderboardResponse {
|
||||
rows: ApiLeaderboardRow[];
|
||||
season: ApiHistorySeason;
|
||||
matchedUserIds?: string[];
|
||||
}
|
||||
|
||||
export interface ApiLeaderHighlight {
|
||||
@@ -681,6 +692,7 @@ export interface ApiTeamInsightsResponse {
|
||||
red: number;
|
||||
bluePicks: number;
|
||||
redPicks: number;
|
||||
confirmed?: { sampleSize: number; blue: number; red: number };
|
||||
};
|
||||
topKda: ApiLeaderHighlight | null;
|
||||
mostKills: ApiLeaderHighlight | null;
|
||||
@@ -692,8 +704,14 @@ export interface ApiTeamInsightsResponse {
|
||||
|
||||
export interface ApiInternalMatchDetailResponse {
|
||||
match: ApiInternalMatchCard;
|
||||
competition?: InternalMatchCompetition;
|
||||
games: Array<{
|
||||
gameNumber: number;
|
||||
gameId?: GameId;
|
||||
analysisAvailability?: GameAnalysisAvailability;
|
||||
gameSlotId?: GameSlotId;
|
||||
seriesId?: SeriesId;
|
||||
ordinal?: number;
|
||||
riotMatchId: string;
|
||||
gameCreation: number;
|
||||
gameDuration: number;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { InteractionStatus } from '@azure/msal-browser';
|
||||
import { useMsal } from '@azure/msal-react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { io, type Socket } from 'socket.io-client';
|
||||
import { API_BASE_URL, useAuthUserId } from '../config';
|
||||
import { acquireAccessToken } from '../lib/auth/token-provider';
|
||||
import { isMsalConfigured } from '../lib/auth/msal.config';
|
||||
import type { ApiAuction, ApiAuctionChatMessage, Position } from './types';
|
||||
import {
|
||||
createAuctionResyncRequester,
|
||||
@@ -140,8 +143,14 @@ function mergeChatMessages(
|
||||
|
||||
export function useAuctionSocket(matchId: string | undefined) {
|
||||
const authUserId = useAuthUserId();
|
||||
const connectionKey = matchId
|
||||
? JSON.stringify([matchId, authUserId ?? null])
|
||||
const { accounts, inProgress, instance } = useMsal();
|
||||
const accountId = isMsalConfigured
|
||||
? (instance.getActiveAccount() ?? accounts[0])?.homeAccountId
|
||||
: undefined;
|
||||
const waitingForLogin = isMsalConfigured && !authUserId &&
|
||||
(inProgress === InteractionStatus.Startup || inProgress === InteractionStatus.HandleRedirect);
|
||||
const connectionKey = matchId && !waitingForLogin
|
||||
? JSON.stringify([matchId, authUserId ?? null, accountId ?? null])
|
||||
: null;
|
||||
const socketRef = useRef<Socket | null>(null);
|
||||
const resyncRequesterRef = useRef<ReturnType<
|
||||
|
||||
Reference in new issue
Block a user