first pass of new server page
This commit is contained in:
parent
23a1f7708b
commit
990013af2b
9 changed files with 443 additions and 57 deletions
43
app/utils/sorting.ts
Normal file
43
app/utils/sorting.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
import type { MetagameWorld } from "./metagame";
|
||||
|
||||
export const contPrioritySort = (
|
||||
a: MetagameWorld["zones"][number],
|
||||
b: MetagameWorld["zones"][number]
|
||||
) => {
|
||||
// Sort priority:
|
||||
// 1. oldest alert
|
||||
// 2. unlocked by id
|
||||
// 3. oldest locked since
|
||||
|
||||
if (a.locked && !b.locked) {
|
||||
return 1;
|
||||
} else if (!a.locked && b.locked) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (a.alert && b.alert) {
|
||||
return Date.parse(a.alert.start_time) - Date.parse(b.alert.start_time);
|
||||
}
|
||||
|
||||
if (a.alert) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (b.alert) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (a.locked_since && b.locked_since) {
|
||||
return Date.parse(a.locked_since) - Date.parse(b.locked_since);
|
||||
}
|
||||
|
||||
if (a.locked_since) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (b.locked_since) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue