Fix match page slowness (#2573)

This commit is contained in:
Kalle 2025-10-13 18:46:56 +03:00 committed by GitHub
parent 88dcd43741
commit 54ef0305a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 32 additions and 19 deletions

View File

@ -130,12 +130,14 @@ export const loader = async ({ params, request }: LoaderFunctionArgs) => {
maps: match.maps, maps: match.maps,
pickBanEvents, pickBanEvents,
recentlyPlayedMaps: recentlyPlayedMaps:
await TournamentTeamRepository.findRecentlyPlayedMapsByIds({ match.mapPickingStyle !== "TO"
teamIds: [match.opponentOne.id, match.opponentTwo.id], ? await TournamentTeamRepository.findRecentlyPlayedMapsByIds({
}).catch((error) => { teamIds: [match.opponentOne.id, match.opponentTwo.id],
logger.error("Failed to fetch recently played maps", error); }).catch((error) => {
return []; logger.error("Failed to fetch recently played maps", error);
}), return [];
})
: undefined,
}).map((mapListMap) => { }).map((mapListMap) => {
return { return {
map: { map: {

View File

@ -95,12 +95,14 @@ export const action: ActionFunction = async ({ params, request }) => {
maps: match.roundMaps, maps: match.roundMaps,
pickBanEvents, pickBanEvents,
recentlyPlayedMaps: recentlyPlayedMaps:
await TournamentTeamRepository.findRecentlyPlayedMapsByIds({ match.mapPickingStyle !== "TO"
teamIds: [match.opponentOne.id, match.opponentTwo.id], ? await TournamentTeamRepository.findRecentlyPlayedMapsByIds({
}).catch((error) => { teamIds: [match.opponentOne.id, match.opponentTwo.id],
logger.error("Failed to fetch recently played maps", error); }).catch((error) => {
return []; logger.error("Failed to fetch recently played maps", error);
}), return [];
})
: undefined,
}) })
: null; : null;

View File

@ -30,7 +30,7 @@ interface ResolveCurrentMapListArgs {
type: Tables["TournamentMatchPickBanEvent"]["type"]; type: Tables["TournamentMatchPickBanEvent"]["type"];
}>; }>;
/** Maps that both teams (interleaved) have recently played in the tournament with the most recent being first. */ /** Maps that both teams (interleaved) have recently played in the tournament with the most recent being first. */
recentlyPlayedMaps: Array<{ mode: ModeShort; stageId: StageId }>; recentlyPlayedMaps?: Array<{ mode: ModeShort; stageId: StageId }>;
} }
export function resolveMapList( export function resolveMapList(

View File

@ -37,12 +37,14 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
maps: match.roundMaps, maps: match.roundMaps,
pickBanEvents, pickBanEvents,
recentlyPlayedMaps: recentlyPlayedMaps:
await TournamentTeamRepository.findRecentlyPlayedMapsByIds({ match.mapPickingStyle !== "TO"
teamIds: [match.opponentOne.id, match.opponentTwo.id], ? await TournamentTeamRepository.findRecentlyPlayedMapsByIds({
}).catch((error) => { teamIds: [match.opponentOne.id, match.opponentTwo.id],
logger.error("Failed to fetch recently played maps", error); }).catch((error) => {
return []; logger.error("Failed to fetch recently played maps", error);
}), return [];
})
: undefined,
}) })
: null; : null;

View File

@ -0,0 +1,7 @@
export function up(db) {
db.transaction(() => {
db.prepare(
/* sql */ `create index idx_tmgrp_tournament_team_id on "TournamentMatchGameResultParticipant"("tournamentTeamId")`,
).run();
})();
}