booking operations and trains scheduling also allocations

This commit is contained in:
marshal
2026-06-10 00:48:32 +03:00
parent 675975bc08
commit 5774d7db9d
180 changed files with 13423 additions and 3877 deletions

View File

@@ -0,0 +1,19 @@
export interface SchedulingPriorityBooking {
isGovernment?: boolean;
priorityScore?: number | null;
scheduledDate: Date | string;
}
/** Government first, then priority score, then earliest scheduled date. */
export function compareSchedulingPriority(
a: SchedulingPriorityBooking,
b: SchedulingPriorityBooking,
): number {
const govDiff = Number(Boolean(b.isGovernment)) - Number(Boolean(a.isGovernment));
if (govDiff !== 0) return govDiff;
const priorityDiff = (b.priorityScore ?? 0) - (a.priorityScore ?? 0);
if (priorityDiff !== 0) return priorityDiff;
return new Date(a.scheduledDate).getTime() - new Date(b.scheduledDate).getTime();
}