From 8e0acb7bc887cb673a9da0d2c29110d182a54825 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sat, 25 Oct 2025 15:07:36 +0200 Subject: [PATCH] removing tournaments from index that has already started --- .env_example => .env | 0 .../(tournament)/tournament/+page.svelte | 27 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) rename .env_example => .env (100%) diff --git a/.env_example b/.env similarity index 100% rename from .env_example rename to .env diff --git a/web/src/routes/(tournament)/tournament/+page.svelte b/web/src/routes/(tournament)/tournament/+page.svelte index 8157bc9..9b33765 100644 --- a/web/src/routes/(tournament)/tournament/+page.svelte +++ b/web/src/routes/(tournament)/tournament/+page.svelte @@ -7,14 +7,19 @@ let tournamentList = $state(props.data.tournaments ?? []); function sortTournaments(list: TournamentInfo[]): TournamentInfo[] { - return [...list].sort((a, b) => { - const timeA = a.start_at ? new Date(a.start_at).getTime() : Number.POSITIVE_INFINITY; - const timeB = b.start_at ? new Date(b.start_at).getTime() : Number.POSITIVE_INFINITY; - if (!Number.isNaN(timeA) && !Number.isNaN(timeB) && timeA !== timeB) { - return timeA - timeB; - } - return a.title.localeCompare(b.title, 'sv'); - }); + const now = new Date().getTime(); + return [...list] + .filter( + (tournament) => !tournament.start_at || new Date(tournament.start_at).getTime() >= now + ) + .sort((a, b) => { + const timeA = a.start_at ? new Date(a.start_at).getTime() : Number.POSITIVE_INFINITY; + const timeB = b.start_at ? new Date(b.start_at).getTime() : Number.POSITIVE_INFINITY; + if (!Number.isNaN(timeA) && !Number.isNaN(timeB) && timeA !== timeB) { + return timeA - timeB; + } + return a.title.localeCompare(b.title, 'sv'); + }); } const tournaments = $derived(() => sortTournaments(tournamentList)); @@ -82,7 +87,7 @@
-

VBytes LAN

+

VBytes LAN

Turneringar

@@ -91,9 +96,9 @@ {#each tournaments() as tournament}
-
+
{tournament.game}