add CUSTOMS type to priority configs and update related logic

This commit is contained in:
Marshal
2026-07-07 16:42:57 +00:00
parent f300600bfa
commit b57840c907
26 changed files with 352 additions and 120 deletions

View File

@@ -3912,14 +3912,16 @@ export class TrainSchedulingService {
AND ts.window_phase IS NOT NULL
AND ts.window_phase NOT IN ('DONE', 'CLOSED_FOR_DAY')
AND ts.scheduled_departure_date >= now()
ORDER BY ts.id, c.id NULLS LAST, ts.window_opens_at ASC NULLS LAST`,
ORDER BY ts.id, c.id NULLS LAST, ts.scheduled_departure_date ASC NULLS LAST`,
[companyId],
);
// Nearest dispatch (departure) date first — the DISTINCT ON above forces a
// per-row ordering, so re-sort the mapped rows by departure for the client.
return rows
.map((r) => this.mapBookingWindowRow(r))
.sort((a, b) => {
const ta = a.windowOpensAt ? new Date(a.windowOpensAt).getTime() : Infinity;
const tb = b.windowOpensAt ? new Date(b.windowOpensAt).getTime() : Infinity;
const ta = a.departureDate ? new Date(a.departureDate).getTime() : Infinity;
const tb = b.departureDate ? new Date(b.departureDate).getTime() : Infinity;
return ta - tb;
});
}
@@ -3961,7 +3963,7 @@ export class TrainSchedulingService {
AND ts.window_phase IS NOT NULL
AND ts.window_phase NOT IN ('DONE', 'CLOSED_FOR_DAY')
AND ts.scheduled_departure_date >= now()
ORDER BY ts.window_opens_at ASC NULLS LAST`,
ORDER BY ts.scheduled_departure_date ASC NULLS LAST`,
[contractId],
);
return rows.map((r) => this.mapBookingWindowRow(r));
@@ -3999,7 +4001,7 @@ export class TrainSchedulingService {
AND ts.window_phase IS NOT NULL
AND ts.window_phase NOT IN ('DONE', 'CLOSED_FOR_DAY')
AND ts.scheduled_departure_date >= now()
ORDER BY ts.window_opens_at ASC NULLS LAST`,
ORDER BY ts.scheduled_departure_date ASC NULLS LAST`,
);
return rows.map((r) => ({
...this.mapBookingWindowRow({