mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 14:20:58 +00:00
20 lines
637 B
TypeScript
20 lines
637 B
TypeScript
export interface SchedulingPriorityRow {
|
|
isGovernment?: boolean;
|
|
priorityScore?: number;
|
|
scheduledDate: string;
|
|
}
|
|
|
|
/** Government first, then priority score, then earliest scheduled date. */
|
|
export function compareSchedulingPriority(
|
|
a: SchedulingPriorityRow,
|
|
b: SchedulingPriorityRow,
|
|
): 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();
|
|
}
|