mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 06:28:12 +00:00
fix(passenger-api): fix seed errors and add missing stop times
This commit is contained in:
@@ -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([
|
await Promise.all([
|
||||||
...coachAssignments.map(ca => prisma.coachAssignment.create({ data: ca })),
|
...coachAssignments.map(ca => prisma.coachAssignment.create({ data: ca })),
|
||||||
...liveStatuses.map(ls => prisma.tripLiveStatus.create({ data: ls })),
|
...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() {
|
async function seedFareRules() {
|
||||||
|
|||||||
Reference in New Issue
Block a user