Skip to content

Commit

Permalink
feat: ✨ getAllStructureMatchUps: support participantsProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
CourtHive committed Jun 11, 2024
1 parent 209723a commit 7fbfbcb
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/query/matchUps/getAllStructureMatchUps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { structureAssignedDrawPositions } from '@Query/drawDefinition/positionsG
import { resolveTieFormat } from '@Query/hierarchical/tieFormats/resolveTieFormat';
import { getCollectionPositionMatchUps } from './getCollectionPositionMatchUps';
import { getMatchUpsMap, getMappedStructureMatchUps } from './getMatchUpsMap';
import { hydrateParticipants } from '@Query/participants/hydrateParticipants';
import { getSourceDrawPositionRanges } from './getSourceDrawPositionRanges';
import { getAppliedPolicies } from '@Query/extensions/getAppliedPolicies';
import { getContextContent } from '@Query/hierarchical/getContextContent';
Expand All @@ -24,6 +25,7 @@ import {
MatchUpFilters,
MatchUpsMap,
ParticipantMap,
ParticipantsProfile,
PolicyDefinitions,
ScheduleTiming,
ScheduleVisibilityFilters,
Expand All @@ -37,6 +39,7 @@ import {
type GetAllStructureMatchUps = {
scheduleVisibilityFilters?: ScheduleVisibilityFilters;
tournamentAppliedPolicies?: PolicyDefinitions;
participantsProfile?: ParticipantsProfile;
tournamentParticipants?: Participant[];
policyDefinitions?: PolicyDefinitions;
seedAssignments?: SeedAssignment[];
Expand All @@ -52,6 +55,7 @@ type GetAllStructureMatchUps = {
contextProfile?: ContextProfile;
tournamentRecord?: Tournament;
afterRecoveryTimes?: boolean;
useParticipantMap?: boolean;
usePublishState?: boolean;
exitProfiles?: ExitProfiles;
matchUpsMap?: MatchUpsMap;
Expand Down Expand Up @@ -210,17 +214,30 @@ export function getAllStructureMatchUps(params: GetAllStructureMatchUps) {
}).drawPositionsRanges
: undefined;

let tournamentParticipants = params.tournamentParticipants;
let participantMap = params.participantMap;

if (!tournamentParticipants?.length && !participantMap && tournamentRecord) {
({ participants: tournamentParticipants = [], participantMap } = hydrateParticipants({
participantsProfile: params.participantsProfile,
useParticipantMap: params.useParticipantMap,
policyDefinitions: params.policyDefinitions,
tournamentRecord,
contextProfile,
inContext,
}));
}

matchUps = matchUps.map((matchUp) => {
return addMatchUpContext({
tournamentParticipants: params.tournamentParticipants ?? tournamentRecord?.participants,
scheduleVisibilityFilters: params.scheduleVisibilityFilters,
hydrateParticipants: params.hydrateParticipants,
afterRecoveryTimes: params.afterRecoveryTimes,
usePublishState: params.usePublishState,
participantMap: params.participantMap,
scheduleTiming: params.scheduleTiming,
publishStatus: params.publishStatus,
sourceDrawPositionRanges,
tournamentParticipants,
positionAssignments,
drawPositionsRanges,
initialRoundOfPlay,
Expand All @@ -229,6 +246,7 @@ export function getAllStructureMatchUps(params: GetAllStructureMatchUps) {
appliedPolicies,
seedAssignments,
contextContent,
participantMap,
contextProfile,
drawDefinition,
scoringActive,
Expand Down

0 comments on commit 7fbfbcb

Please sign in to comment.