Skip to content

Commit

Permalink
fix: 🐛 attach tieFormat to added qualifying structures
Browse files Browse the repository at this point in the history
  • Loading branch information
CourtHive committed Nov 28, 2024
1 parent f79c3d6 commit a76e784
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,38 @@ import { decorateResult } from '@Functions/global/decorateResult';
import { coerceEven, isConvertableInteger } from '@Tools/math';
import { addExtension } from '@Mutate/extensions/addExtension';
import { generateRoundRobin } from './roundRobin/roundRobin';
import { treeMatchUps } from './eliminationTree';
import { constantToString } from '@Tools/strings';
import { treeMatchUps } from './eliminationTree';

// constants and types
import { POSITION, QUALIFYING, ROUND_ROBIN, WINNER } from '@Constants/drawDefinitionConstants';
import { MISSING_DRAW_SIZE } from '@Constants/errorConditionConstants';
import { DrawLink, Structure } from '@Types/tournamentTypes';
import { DrawLink, Structure, TieFormat } from '@Types/tournamentTypes';
import { PolicyDefinitions, ResultType } from '@Types/factoryTypes';
import { ROUND_TARGET } from '@Constants/extensionConstants';
import { SUCCESS } from '@Constants/resultConstants';
import { ResultType } from '@Types/factoryTypes';

type GenerateQualifyingStructuresArgs = {
hasExistingDrawDefinition?: boolean;
appliedPolicies?: PolicyDefinitions;
qualifyingProfiles: any[];
qualifyingOnly?: boolean;
tieFormat?: TieFormat;
idPrefix?: string;
isMock?: boolean;
uuids?: string[];
};

export function generateQualifyingStructures({
hasExistingDrawDefinition,
qualifyingProfiles,
appliedPolicies,
qualifyingOnly,
tieFormat,
idPrefix,
isMock,
uuids,
}): ResultType & {
}: GenerateQualifyingStructuresArgs): ResultType & {
qualifyingDrawPositionsCount?: number;
structures?: Structure[];
qualifiersCount?: number;
Expand Down Expand Up @@ -115,6 +127,7 @@ export function generateQualifyingStructures({
structureName: structureProfile.structureName || qualifyingStructureName,
structureId: structureId || uuids?.pop(),
qualifyingRoundNumber: roundLimit,
hasExistingDrawDefinition,
stage: QUALIFYING,
qualifyingOnly,
matchUpFormat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function processExistingDrawDefinition(params): ResultType & {
const qualifyingProfiles = params.qualifyingProfiles;
const qualifyingResult = qualifyingProfiles?.length
? generateQualifyingStructures({
hasExistingDrawDefinition: true,
uuids: params.uuids,
qualifyingProfiles,
appliedPolicies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { ResultType } from '@Types/factoryTypes';
export function qualifyingGeneration(params): ResultType & { qualifyingConflicts?: any[] } {
const {
qualifyingPlaceholder,
qualifyingProfiles,
existingDrawDefinition,
positioningReports,
qualifyingProfiles,
appliedPolicies,
qualifyingOnly,
drawDefinition,
Expand Down
4 changes: 3 additions & 1 deletion src/assemblies/generators/templates/structureTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ROUND_OUTCOME } from '@Constants/drawDefinitionConstants';
import { SeedingProfile } from '@Types/factoryTypes';

type StructureTemplateArgs = {
hasExistingDrawDefinition?: boolean;
seedAssignments?: SeedAssignment[];
qualifyingRoundNumber?: number;
structureAbbreviation?: string;
Expand All @@ -31,6 +32,7 @@ type StructureTemplateArgs = {

export const structureTemplate = ({
finishingPosition = ROUND_OUTCOME,
hasExistingDrawDefinition,
qualifyingRoundNumber,
structureAbbreviation,
seedAssignments = [],
Expand Down Expand Up @@ -61,9 +63,9 @@ export const structureTemplate = ({
structureName,
};

if (qualifyingOnly || (hasExistingDrawDefinition && tieFormat)) structure.tieFormat = tieFormat;
if (structureOrder) structure.structureOrder = structureOrder;
if (structureType) structure.structureType = structureType;
if (qualifyingOnly) structure.tieFormat = tieFormat;
if (seedingProfile) {
if (typeof seedingProfile === 'string') {
structure.seedingProfile = seedingProfile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { attachPolicies } from '@Mutate/extensions/policies/attachPolicies';
import { getDrawStructures } from '@Acquire/findStructure';
import { generateRange } from '@Tools/arrays';

import SEEDING_POLICY from '@Fixtures/policies/POLICY_SEEDING_ITF';
// Constants and Fixtures
import { MAIN, FIRST_MATCH_LOSER_CONSOLATION, CONSOLATION } from '@Constants/drawDefinitionConstants';
import SEEDING_POLICY from '@Fixtures/policies/POLICY_SEEDING_ITF';

// NOTE: replace all other occurrences of this function with this one

Expand Down

0 comments on commit a76e784

Please sign in to comment.