fix: sort upcoming fixtures by UTC kickoff time, not venue local HH:MM

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 <noreply@anthropic.com>
This commit is contained in:
2026-06-15 19:37:41 +02:00
parent 015f6c2ef3
commit 76425e7f76
+11 -1
View File
@@ -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 }