mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
Commiting stop based booking
This commit is contained in:
@@ -23,6 +23,17 @@ export const IDS = {
|
||||
/** Route stop distances (km from origin). A=0, B=100, C=250 → A→B is 100km, A→C is 250km. */
|
||||
export const DISTANCE = { A: 0, B: 100, C: 250 } as const;
|
||||
|
||||
/**
|
||||
* Optional per-stop check-in-cutoff/travel-time overrides, keyed by station label (A/B/C).
|
||||
* Lets a spec seed a distinct `checkinMinutesBefore` override and/or `travelMinutesToStop`
|
||||
* per stop without changing the zero-arg call sites the other specs rely on.
|
||||
*/
|
||||
export interface RouteStopOverrides {
|
||||
A?: { checkinMinutesBefore?: number; travelMinutesToStop?: number };
|
||||
B?: { checkinMinutesBefore?: number; travelMinutesToStop?: number };
|
||||
C?: { checkinMinutesBefore?: number; travelMinutesToStop?: number };
|
||||
}
|
||||
|
||||
/**
|
||||
* FX rate chosen so the seat-class distance formula (which multiplies an ETB/km rate by the
|
||||
* USD→ETB rate — see fare-engine.service.ts:157) yields whole ETB-minor amounts. 100 makes the
|
||||
@@ -45,7 +56,7 @@ export async function truncateAllPassenger(prisma: PrismaClient): Promise<void>
|
||||
}
|
||||
|
||||
/** Insert the deterministic core graph. Call after truncateAllPassenger. */
|
||||
export async function seedCore(prisma: PrismaClient): Promise<void> {
|
||||
export async function seedCore(prisma: PrismaClient, stopOverrides: RouteStopOverrides = {}): Promise<void> {
|
||||
const past = new Date("2020-01-01T00:00:00.000Z");
|
||||
|
||||
await prisma.coachType.create({
|
||||
@@ -103,9 +114,9 @@ export async function seedCore(prisma: PrismaClient): Promise<void> {
|
||||
active: true,
|
||||
stops: {
|
||||
create: [
|
||||
{ stationId: IDS.stationA, sequence: 1, distanceKm: DISTANCE.A },
|
||||
{ stationId: IDS.stationB, sequence: 2, distanceKm: DISTANCE.B },
|
||||
{ stationId: IDS.stationC, sequence: 3, distanceKm: DISTANCE.C },
|
||||
{ stationId: IDS.stationA, sequence: 1, distanceKm: DISTANCE.A, ...stopOverrides.A },
|
||||
{ stationId: IDS.stationB, sequence: 2, distanceKm: DISTANCE.B, ...stopOverrides.B },
|
||||
{ stationId: IDS.stationC, sequence: 3, distanceKm: DISTANCE.C, ...stopOverrides.C },
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -122,7 +133,7 @@ export async function seedCore(prisma: PrismaClient): Promise<void> {
|
||||
}
|
||||
|
||||
/** Convenience: reset + seed in one call. */
|
||||
export async function resetAndSeedCore(prisma: PrismaClient): Promise<void> {
|
||||
export async function resetAndSeedCore(prisma: PrismaClient, stopOverrides: RouteStopOverrides = {}): Promise<void> {
|
||||
await truncateAllPassenger(prisma);
|
||||
await seedCore(prisma);
|
||||
await seedCore(prisma, stopOverrides);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user