update team sorting
All checks were successful
deploy / build-and-deploy (/testvaro, /opt/website-test, website-test) (push) Successful in 20s
deploy / build-and-deploy (/varo, /opt/website, website) (push) Successful in 23s

This commit is contained in:
2025-06-23 21:12:00 +02:00
parent 55f5f25e5a
commit 6e4a7f0ac9

View File

@ -20,14 +20,16 @@
kills: deaths.filter((d) => d.killerUserId === team.memberOne.id || d.killerUserId === team.memberTwo.id).length
}));
entries.sort((a, b) => {
const aAllowed =
!!a.memberOne.id && !!a.memberTwo.id && !(a.memberOne.deathMessage !== null && a.memberTwo.deathMessage !== null);
const bAllowed =
!!b.memberOne.id && !!b.memberTwo.id && !(b.memberOne.deathMessage !== null && b.memberTwo.deathMessage !== null);
if (!aAllowed && !bAllowed) {
return 0;
} else if (!aAllowed || !bAllowed) {
return (bAllowed as unknown as number) - (aAllowed as unknown as number);
const aBothSignedUp = a.memberOne.id != null && a.memberTwo.id != null;
const aBothDeathMessage = a.memberOne.deathMessage != null && a.memberTwo.deathMessage != null;
const bBothSignedUp = b.memberOne.id != null && b.memberTwo.id != null;
const bBothDeathMessage = b.memberOne.deathMessage != null && b.memberTwo.deathMessage != null;
if (!aBothSignedUp || !bBothSignedUp) {
return Number(bBothSignedUp) - Number(aBothSignedUp);
} else if (aBothDeathMessage && !bBothDeathMessage || !aBothDeathMessage && bBothDeathMessage) {
return Number(aBothDeathMessage) - Number(bBothDeathMessage);
}
return b.kills - a.kills;