Skip to content

Commit

Permalink
refactor: 🚸 improve anonymizer for tournamentrecords; remove onlineRe…
Browse files Browse the repository at this point in the history
…sources, venue addresses
  • Loading branch information
CourtHive committed Apr 15, 2024
1 parent eb99eb8 commit ea9f1d4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export function anonymizeTournamentRecord({
delete tournamentRecord.parentOrganisation;

for (const participant of tournamentRecord.participants || []) {
participant.extensions = filterExtensions(participant);
participant.onlineResources = [];

const newParticipantId = UUID();
idMap[participant.participantId] = newParticipantId;
participant.participantId = newParticipantId;
Expand All @@ -70,19 +73,34 @@ export function anonymizeTournamentRecord({

let venueIndex = 0;
for (const venue of tournamentRecord.venues || []) {
venue.venueAbbreviation = `V${venueIndex}`;
venue.extensions = filterExtensions(venue);
venue.venueName = `Venue #${venueIndex}`;
venue.venueAbbreviation = `V${venueIndex}`;

venue.onlineResources = [];
venue.addresses = [];

const newVenueId = UUID();
idMap[venue.venueId] = newVenueId;

venue.isMock = true;
venueIndex += 1;
// venue.eventId = UUID(); eventIds can't be anonymized without updating schedulingProfiles

let courtIndex = 0;
for (const court of venue.courts || []) {
court.courtName = `V${venueIndex}C${courtIndex}`;
court.extensions = filterExtensions(court);
court.onlineResources = [];
court.isMock = true;
courtIndex += 1;
}
}

let eventCount = 1;
for (const event of tournamentRecord.events || []) {
event.extensions = filterExtensions(event);
event.onlineResources = [];
event.isMock = true;

const newEventId = UUID();
Expand Down
6 changes: 2 additions & 4 deletions src/mutate/matchUps/matchUpStatus/setMatchUpState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ export function setMatchUpState(params: SetMatchUpStateArgs): any {
].includes(matchUpStatus)
) {
return {
error: INVALID_VALUES,
info: 'Not supported for matchUpType: TEAM',
error: INVALID_VALUES,
};
}

Expand All @@ -243,9 +243,7 @@ export function setMatchUpState(params: SetMatchUpStateArgs): any {
winningSide,
score,
});
if (result.error) {
return result;
}
if (result.error) return result;
}

const appliedPolicies =
Expand Down

0 comments on commit ea9f1d4

Please sign in to comment.