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,
pickBanEvents,
recentlyPlayedMaps:
await TournamentTeamRepository.findRecentlyPlayedMapsByIds({
teamIds: [match.opponentOne.id, match.opponentTwo.id],
}).catch((error) => {
logger.error("Failed to fetch recently played maps", error);
return [];
}),
match.mapPickingStyle !== "TO"
? await TournamentTeamRepository.findRecentlyPlayedMapsByIds({
teamIds: [match.opponentOne.id, match.opponentTwo.id],
}).catch((error) => {
logger.error("Failed to fetch recently played maps", error);
return [];
})
: undefined,
}).map((mapListMap) => {
return {
map: {

View File

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

View File

@ -30,7 +30,7 @@ interface ResolveCurrentMapListArgs {
type: Tables["TournamentMatchPickBanEvent"]["type"];
}>;
/** 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(

View File

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