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:
@@ -134,7 +134,17 @@ export const resolvers = {
|
|||||||
sql`${matches.scoreFtHome} IS NULL`,
|
sql`${matches.scoreFtHome} IS NULL`,
|
||||||
eq(matches.isQualiPlayoff, false),
|
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)
|
.limit(limit)
|
||||||
return Promise.all(rows.map(hydrateMatch))
|
return Promise.all(rows.map(hydrateMatch))
|
||||||
} catch (e) { if (isMissingTable(e)) return []; throw e }
|
} catch (e) { if (isMissingTable(e)) return []; throw e }
|
||||||
|
|||||||
Reference in New Issue
Block a user