From d07f522a606cd1d1d59ede09bb84de35500ce820 Mon Sep 17 00:00:00 2001 From: Abubeker Yasin Date: Mon, 8 Jun 2026 12:00:01 +0300 Subject: [PATCH] fix(passenger-api): fix seed errors and add missing stop times --- apps/edr-passenger-api/prisma/seed.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/edr-passenger-api/prisma/seed.ts b/apps/edr-passenger-api/prisma/seed.ts index f29815996..9aff71529 100644 --- a/apps/edr-passenger-api/prisma/seed.ts +++ b/apps/edr-passenger-api/prisma/seed.ts @@ -311,12 +311,31 @@ async function seedTrips() { }); } + // Stop times: one TripStopTime per station per schedule + const stationCodes = ['SBT', 'LEB', 'BSH', 'MOJ', 'ADM', 'MTE', 'MIS', 'BIK', 'DRE', 'ADG', 'AYS', 'DAW', 'ALS', 'HOL', 'NAG']; + const stopTimeRows = []; + for (const schedule of createdSchedules) { + const dep = new Date(schedule.departureAt); + for (let i = 0; i < stationCodes.length; i++) { + const stationId = `station-${stationCodes[i].toLowerCase()}`; + const offsetMs = i * 60 * 60 * 1000; // ~1 hour between stops + stopTimeRows.push({ + scheduleId: schedule.id, + stationId, + sequence: i + 1, + plannedArrivalAt: i === 0 ? null : new Date(dep.getTime() + offsetMs), + plannedDepartureAt: i === stationCodes.length - 1 ? null : new Date(dep.getTime() + offsetMs), + }); + } + } + await Promise.all([ ...coachAssignments.map(ca => prisma.coachAssignment.create({ data: ca })), ...liveStatuses.map(ls => prisma.tripLiveStatus.create({ data: ls })), + prisma.tripStopTime.createMany({ data: stopTimeRows }), ]); - - console.log(` ✅ Train with ${createdSchedules.length} upcoming trips created`); + + console.log(` ✅ Train with ${createdSchedules.length} upcoming trips and stop times created`); } async function seedFareRules() {