fix: sort recentMatches by UTC kickoff time, not ID

ID order doesn't reflect actual match time — a later kickoff in a
different timezone can have a lower ID. Use the same UTC normalisation
expression as upcomingMatches so the latest finished match always
appears first.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-16 01:44:38 +02:00
parent 7fb54683e4
commit 1fc9c59367
+11 -1
View File
@@ -120,7 +120,17 @@ export const resolvers = {
isNotNull(matches.scoreFtHome),
eq(matches.isQualiPlayoff, false),
))
.orderBy(desc(matches.date), desc(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 DESC NULLS LAST`,
desc(matches.id),
)
.limit(limit * 2)
const hydrated = await Promise.all(rows.map(hydrateMatch))
return hydrated.filter(m => !m.isLive).slice(0, limit)