Skip to content

Commit 9ae67bf

Browse files
committed
fix DOO duplicates
1 parent 243c12d commit 9ae67bf

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/creators/createJourneyResponse.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,14 +523,15 @@ export async function createJourneyResponse(
523523
for (const virtualStopEvent of virtualStopEvents) {
524524
const { event_type, stop } = virtualStopEvent
525525
const canUsePas = ['ARS', 'DEP', 'PDE'].includes(event_type)
526+
const existingEventsForDedupe = [...patchedStopEvents, ...events]
526527

527-
const eventExists = patchedStopEvents.some((evt) => {
528+
const eventExists = existingEventsForDedupe.some((evt) => {
528529
// Skip virtual departure events when a PAS event for the stop exists
529530
if (canUsePas && evt.event_type === 'PAS' && evt.stop === stop) {
530531
return true
531532
}
532533

533-
return evt.event_type + evt.stop === event_type + stop
534+
return evt.event_type === event_type && String(evt.stop) === String(stop)
534535
})
535536

536537
if (!eventExists) {

0 commit comments

Comments
 (0)