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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user