Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
CourtHive committed Jun 11, 2024
2 parents 5d61c1d + 7fbfbcb commit 8440be5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
4 changes: 3 additions & 1 deletion documentation/docs/governors/query-governor.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ const {
structures,
} = engine.getDrawData({
allParticipantResults, // optional boolean; include round statistics per structure even for elimination structures
drawDefinition,
contextProfile, // optional: { inferGender: true, withCompetitiveness: true, withScaleValues: true, exclude: ['attribute', 'to', 'exclude']}
drawId,
});
```

Expand Down Expand Up @@ -464,6 +465,7 @@ const { eventData } = engine.getEventData({
participantsProfile, // optional - ability to specify additions to context (see parameters of getParticipants())
policyDefinitions, // optional
usePublishState, // optional - filter out draws which are not published
contextProfile, // optional: { inferGender: true, withCompetitiveness: true, withScaleValues: true, exclude: ['attribute', 'to', 'exclude']}
eventId,
});
const { drawsData, venuesData, eventInfo, tournamentInfo } = eventData;
Expand Down
3 changes: 3 additions & 0 deletions src/query/drawDefinition/getDrawData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export function getDrawData(params): {
status = PUBLIC,
pressureRating,
refreshResults,
contextProfile,
drawDefinition,
noDeepCopy,
sortConfig,
Expand Down Expand Up @@ -125,11 +126,13 @@ export function getDrawData(params): {
seedAssignments: !structure?.seedAssignments?.length ? seedAssignments : undefined,
context: { drawId: drawInfo.drawId, ...context },
hydrateParticipants: params.hydrateParticipants,
participantsProfile: params.participantsProfile,
tournamentParticipants,
policyDefinitions,
tournamentRecord,
usePublishState,
publishStatus,
contextProfile,
drawDefinition,
inContext,
structure,
Expand Down
3 changes: 3 additions & 0 deletions src/query/event/getEventData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type GetEventDataArgs = {
usePublishState?: boolean;
refreshResults?: boolean;
pressureRating?: boolean;
contextProfile?: any;
eventId?: string;
status?: string;
event?: Event;
Expand All @@ -50,6 +51,7 @@ export function getEventData(params: GetEventDataArgs): {
policyDefinitions,
usePublishState,
status = PUBLIC,
contextProfile,
sortConfig,
} = params;

Expand Down Expand Up @@ -140,6 +142,7 @@ export function getEventData(params: GetEventDataArgs): {
policyDefinitions,
tournamentRecord,
usePublishState,
contextProfile,
drawDefinition,
publishStatus,
sortConfig,
Expand Down
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
4 changes: 4 additions & 0 deletions src/tests/mutations/events/getEventData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ it('returns eventData with expected drawsData', () => {
eventData = tournamentEngine.getEventData({ eventId, usePublishState: true }).eventData;
expect(eventData.eventInfo.published).toEqual(false);
expect(eventData.drawsData).toBeUndefined();

const contextProfile = { withCompetitiveness: true };
eventData = tournamentEngine.getEventData({ eventId, contextProfile }).eventData;
expect(eventData.drawsData[0].structures[0].roundMatchUps[1][0].competitiveProfile.competitiveness).toBeDefined();
});

it('returns eventData when there is no drawsData', () => {
Expand Down

0 comments on commit 8440be5

Please sign in to comment.