From 76425e7f76c6cc9463e868bcf38ad9e4f6103617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Mon, 15 Jun 2026 19:37:41 +0200 Subject: [PATCH] fix: sort upcoming fixtures by UTC kickoff time, not venue local HH:MM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SPLIT_PART sort ignored UTC offsets — a match at 18:00 UTC-7 (01:00 UTC next day) sorted before 12:00 UTC-4 (16:00 UTC same day). Now computes the actual UTC timestamp from date + HH:MM + offset and orders by that. Co-Authored-By: Claude Sonnet 4.6 --- lib/graphql/resolvers/index.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/graphql/resolvers/index.ts b/lib/graphql/resolvers/index.ts index 05ae28b..128b725 100644 --- a/lib/graphql/resolvers/index.ts +++ b/lib/graphql/resolvers/index.ts @@ -134,7 +134,17 @@ export const resolvers = { sql`${matches.scoreFtHome} IS NULL`, eq(matches.isQualiPlayoff, false), )) - .orderBy(asc(matches.date), sql`SPLIT_PART(${matches.timeLocal}, ' ', 1) ASC NULLS LAST`, asc(matches.id)) + .orderBy( + sql`CASE + WHEN ${matches.timeLocal} LIKE '% UTC%' + THEN ${matches.date}::date + + SPLIT_PART(${matches.timeLocal}, ' ', 1)::time + - (REPLACE(SPLIT_PART(${matches.timeLocal}, ' ', 2), 'UTC', '') || ' hours')::interval + ELSE ${matches.date}::date + + COALESCE(NULLIF(SPLIT_PART(${matches.timeLocal}, ' ', 1), '')::time, '00:00'::time) + END ASC NULLS LAST`, + asc(matches.id), + ) .limit(limit) return Promise.all(rows.map(hydrateMatch)) } catch (e) { if (isMissingTable(e)) return []; throw e }