Skip to content

Commit

Permalink
Only remove tickets if the aren't in the pretix response (proofcarryi…
Browse files Browse the repository at this point in the history
robknight authored Nov 13, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 495ca03 commit eb8ea88
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/passport-server/src/services/devconnect/organizerSync.ts
Original file line number Diff line number Diff line change
@@ -824,6 +824,15 @@ export class OrganizerSync {
eventConfigID
);

const pretixTicketsByPositionId = new Map(
ticketsFromPretix.map((ticket) => [ticket.position_id, ticket])
);

// Only remove tickets if they aren't in the Pretix response
const ticketsToRemove = existingTickets.filter((ticket) => {
return !pretixTicketsByPositionId.has(ticket.position_id);
});

const changes = compareArrays(
existingTickets,
approvedTickets,
@@ -878,7 +887,7 @@ export class OrganizerSync {
logger(
`[DEVCONNECT PRETIX] [${eventInfo.event_name}] Deleting ${changes.removed.length} tickets`
);
for (const removedTicket of changes.removed) {
for (const removedTicket of ticketsToRemove) {
logger(
`[DEVCONNECT PRETIX] [${
eventInfo.event_name
6 changes: 6 additions & 0 deletions apps/passport-server/test/devconnect.spec.ts
Original file line number Diff line number Diff line change
@@ -2630,6 +2630,9 @@ describe("devconnect functionality", function () {
// Set up the case where nobody has not agreed to legal terms
await sqlQuery(db, "UPDATE users SET terms_agreed = 0");

// Remove synced tickets from previous tests
await sqlQuery(db, "DELETE FROM devconnect_pretix_tickets");

await os.run();

// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -2806,6 +2809,9 @@ describe("devconnect functionality", function () {
// Set up the case where nobody has not agreed to legal terms
await sqlQuery(db, "UPDATE users SET terms_agreed = 0");

// Remove synced tickets from previous tests
await sqlQuery(db, "DELETE FROM devconnect_pretix_tickets");

await os.run();

// First verify that the user has redacted tickets, and no unredacted ones

0 comments on commit eb8ea88

Please sign in to comment.