This commit is contained in:
dahyeon committed 2026-04-27 19:23:26 -07:00
1 parent 1bbfc901e8
commit 4dba82ca03
18 files changed
+2146 -15

No files matched your search

+114
View File
@@ -16,6 +16,9 @@ import type {
ApiInternalMatchDetailResponse,
ApiInternalMatchListResponse,
ApiLeaderboardResponse,
LegacyImportJobsResponse,
LegacyImportMembersResponse,
LegacyMatchListResponse,
ApiMatch,
ApiRecentMatchesResponse,
ApiRecentSummaryResponse,
@@ -24,6 +27,8 @@ import type {
ApiUserInternalHistoryResponse,
ApiUserHistoryProfile,
DdragonManifest,
StartLegacyImportRequest,
StartLegacyImportResponse,
MatchStatus,
MatchesResponse,
MeResponse,
@@ -505,6 +510,115 @@ export function usePollTournamentResult(communityId = DEFAULT_COMMUNITY_ID) {
});
}
export function useLegacyImportMembers(
options: { windowStart?: string; windowEnd?: string },
communityId = DEFAULT_COMMUNITY_ID,
enabled = true,
) {
return useQuery({
queryKey: [
'legacy-import-members',
communityId,
options.windowStart ?? null,
options.windowEnd ?? null,
],
queryFn: () => {
const searchParams = new URLSearchParams();
if (options.windowStart) searchParams.set('windowStart', options.windowStart);
if (options.windowEnd) searchParams.set('windowEnd', options.windowEnd);
const queryString = searchParams.toString();
return apiFetch<LegacyImportMembersResponse>(
`/communities/${communityId}/legacy-import/members${queryString ? `?${queryString}` : ''}`,
);
},
enabled: Boolean(communityId && enabled),
});
}
export function useLegacyImportJobs(
communityId = DEFAULT_COMMUNITY_ID,
enabled = true,
) {
return useQuery({
queryKey: ['legacy-import-jobs', communityId],
queryFn: () =>
apiFetch<LegacyImportJobsResponse>(
`/communities/${communityId}/legacy-import-jobs?limit=10`,
),
enabled: Boolean(communityId && enabled),
refetchInterval: (query) =>
query.state.data?.jobs.some(
(job) => job.state === 'pending' || job.state === 'running',
)
? 5_000
: false,
});
}
export function useStartLegacyImport(communityId = DEFAULT_COMMUNITY_ID) {
return useMutation({
mutationFn: (body: StartLegacyImportRequest) =>
apiFetch<StartLegacyImportResponse>(
`/communities/${communityId}/legacy-import`,
{
method: 'POST',
body: JSON.stringify(body),
},
),
});
}
export function useCancelLegacyImport(communityId = DEFAULT_COMMUNITY_ID) {
return useMutation({
mutationFn: (jobId: string) =>
apiFetch<void>(
`/communities/${communityId}/legacy-import-jobs/${jobId}/cancel`,
{ method: 'POST' },
),
});
}
export function useLegacyMatches(
communityId = DEFAULT_COMMUNITY_ID,
enabled = true,
) {
return useInfiniteQuery({
queryKey: ['legacy-matches', communityId],
queryFn: ({ pageParam }) => {
const searchParams = new URLSearchParams({ limit: '50' });
if (pageParam) searchParams.set('cursor', String(pageParam));
return apiFetch<LegacyMatchListResponse>(
`/communities/${communityId}/legacy-matches?${searchParams.toString()}`,
);
},
initialPageParam: null as number | null,
getNextPageParam: (lastPage) => lastPage.nextCursor,
enabled: Boolean(communityId && enabled),
});
}
export function useDeleteMatch(communityId = DEFAULT_COMMUNITY_ID) {
return useMutation({
mutationFn: (matchId: string) =>
apiFetch<void>(`/communities/${communityId}/matches/${matchId}`, {
method: 'DELETE',
}),
});
}
export function useBulkDeleteLegacyMatches(communityId = DEFAULT_COMMUNITY_ID) {
return useMutation({
mutationFn: (matchIds: string[]) =>
apiFetch<{ deleted: number }>(
`/communities/${communityId}/legacy-matches/bulk-delete`,
{
method: 'POST',
body: JSON.stringify({ matchIds }),
},
),
});
}
export function useMe() {
const authUserId = useAuthUserId();
const { accounts, inProgress, instance } = useMsal();
+91
View File
@@ -613,6 +613,97 @@ export interface ApiUserInternalHistoryResponse {
lastFetchedAt: string | null;
}
export type LegacyImportJobState =
| 'pending'
| 'running'
| 'completed'
| 'failed'
| 'cancelled';
export interface LegacyImportMemberWindow {
userId: string;
puuid: string;
displayName: string;
gameName: string;
tagLine: string;
profileIconId: number;
isActivated: boolean;
startTime: string;
endTime: string;
}
export interface LegacyImportMembersResponse {
members: LegacyImportMemberWindow[];
}
export interface StartLegacyImportRequest {
windowStart?: string;
windowEnd?: string;
memberOverrides?: Array<{
userId: string;
startTime?: string;
endTime?: string;
}>;
}
export interface StartLegacyImportResponse {
jobId: string;
totalMembers: number;
etaSeconds: number;
}
export interface LegacyImportJob {
_id: string;
jobId: string;
communityId: string;
triggeredBy: string;
startedAt: string;
completedAt?: string;
state: LegacyImportJobState;
windowStart: string;
windowEnd: string;
memberOverrides: Array<{
userId: string;
puuid: string;
startTime: string;
endTime: string;
}>;
totalMembers: number;
processedMembers: number;
totalDiscoveredMatchIds: number;
totalImportedMatches: number;
totalSkippedDuplicate: number;
totalErrors: number;
averageMemberSeconds?: number;
errors?: Array<{
puuid?: string;
matchId?: string;
reason: string;
at: string;
}>;
}
export interface LegacyImportJobsResponse {
jobs: LegacyImportJob[];
}
export interface LegacyMatchListItem {
matchId: string;
title: string;
scheduledAt: string;
riotMatchId: string | null;
memberCount: number;
externalCount: number;
blueScore: number;
redScore: number;
winnerSide?: TeamSide;
}
export interface LegacyMatchListResponse {
matches: LegacyMatchListItem[];
nextCursor: number | null;
}
export type ApiRiotJobPriority = 'high' | 'low';
export type ApiRiotJobState = 'queued' | 'processing' | 'completed' | 'failed';