Skip to content

Commit

Permalink
ensure that ordinal is not undefined
Browse files Browse the repository at this point in the history
fixes #88
  • Loading branch information
jmlee337 committed Dec 20, 2024
1 parent 4a001cb commit ed936e8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/startgg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ export async function getPhaseGroup(
if (existingSet && existingSet.updatedAtMs > updatedAtMs) {
newSet = existingSet;
if (newSet.ordinal === null) {
newSet.ordinal = idToDEOrdinal.get(setId) ?? set.callOrder;
newSet.ordinal = idToDEOrdinal.get(setId) ?? set.callOrder ?? null;
setIdToOrdinal.set(setId, newSet.ordinal);
}
} else {
Expand All @@ -436,7 +436,7 @@ export async function getPhaseGroup(
}

// always record ordinal for gqlSet conversion
const ordinal = idToDEOrdinal.get(setId) ?? set.callOrder;
const ordinal = idToDEOrdinal.get(setId) ?? set.callOrder ?? null;
setIdToOrdinal.set(setId, ordinal);

// skip this set if not fully populated
Expand Down Expand Up @@ -506,8 +506,8 @@ export async function getPhaseGroup(
} while (missingStreamSets.length > 0);
}
}
pendingSets.sort((a, b) => (a.ordinal || a.round) - (b.ordinal || b.round));
completedSets.sort((a, b) => (b.ordinal || b.round) - (a.ordinal || a.round));
pendingSets.sort((a, b) => (a.ordinal ?? a.round) - (b.ordinal ?? b.round));
completedSets.sort((a, b) => (b.ordinal ?? b.round) - (a.ordinal ?? a.round));

idToPhaseGroup.set(id, {
id,
Expand Down Expand Up @@ -832,7 +832,7 @@ function gqlSetToSet(set: any, updatedAtMs: number): Set {
path: set.stream.streamName,
}
: null,
ordinal: setIdToOrdinal.get(set.id) as number | null,
ordinal: setIdToOrdinal.get(set.id) ?? null,
wasReported: reportedSetIds.has(set.id),
updatedAtMs,
};
Expand Down

0 comments on commit ed936e8

Please sign in to comment.