Compare commits

..

2 Commits

Author SHA1 Message Date
valknar 191888225f fix: delete goals once per match instead of once per team in syncGoals()
syncGoals() was calling DELETE FROM goals WHERE match_id=X at the top,
so processing goals2 (away team) wiped out goals1 (home team) that were
just inserted. Every match with goals from both sides lost all home-team
goals — Ronaldo's hat-trick vs Spain, Kane's vs Panama, and many others.

Fix: move DELETE above the goals1/goals2 loop, executed once per match.
Result: 2018 goal count corrected from 107 → 169; hat tricks from 8 → 18.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 17:38:35 +02:00
valknar c418a51f08 chore: remove flags from location text on homepage and history
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 17:30:12 +02:00
3 changed files with 7 additions and 19 deletions
+1 -12
View File
@@ -21,16 +21,6 @@ interface Tournament {
topScorers: Array<{ playerName: string; goals: number; team?: { name: string; iso2?: string | null } | null }>
}
function HostIso(host: string): string {
const map: Record<string, string> = {
'Uruguay': 'uy', 'Italy': 'it', 'France': 'fr', 'Brazil': 'br',
'Switzerland': 'ch', 'Sweden': 'se', 'Chile': 'cl', 'England': 'gb-eng',
'Mexico': 'mx', 'Germany': 'de', 'Argentina': 'ar', 'Spain': 'es',
'South Korea / Japan': 'kr', 'South Africa': 'za', 'Russia': 'ru',
'Qatar': 'qa', 'USA': 'us', 'USA / Canada / Mexico': 'us',
}
return map[host] ?? 'un'
}
export default function HistoryPage() {
const { data, loading } = useQuery(HISTORY_QUERY)
@@ -72,8 +62,7 @@ export default function HistoryPage() {
<div className="flex justify-between items-start mb-3.5">
<div>
<div className="font-['Bebas_Neue'] text-[34px] text-[#22c55e] leading-none">{t.year}</div>
<div className="text-xs text-[#2a5c35] mt-0.5 flex items-center gap-1.5">
<span className={`fi fi-${HostIso(t.host)} rounded-sm text-sm inline-block`} />
<div className="text-xs text-[#2a5c35] mt-0.5">
{t.host}
</div>
</div>
+1 -4
View File
@@ -117,10 +117,7 @@ export default function HomePage() {
World Cup 2026
</h1>
<p className="text-[#2a5c35] text-sm mb-9">
<span className="fi fi-us rounded-sm text-lg mx-0.5 inline-block" /> USA ·{' '}
<span className="fi fi-ca rounded-sm text-lg mx-0.5 inline-block" /> Canada ·{' '}
<span className="fi fi-mx rounded-sm text-lg mx-0.5 inline-block" /> Mexico
&nbsp;·&nbsp; 11 June 19 July 2026 · 48 Teams
USA · Canada · Mexico &nbsp;·&nbsp; 11 June 19 July 2026 · 48 Teams
</p>
<div className="flex gap-2.5 flex-wrap max-w-[760px]">
{stats ? <>
+5 -3
View File
@@ -226,7 +226,6 @@ async function run() {
}
async function syncGoals(matchId: number, teamId: number, rawGoals: RawGoal[], isOwnGoalTeamId: number) {
await db.execute(sql`DELETE FROM goals WHERE match_id = ${matchId}`)
for (const g of rawGoals) {
if (!g.name) continue
const minute = g.minute != null ? parseInt(String(g.minute)) : null
@@ -294,8 +293,11 @@ async function run() {
const score = parseScore(m.score)
const group = m.group ?? null
const matchId = await upsertMatch(year, m.round ?? 'Unknown', group, m.date ?? null, m.time ?? null, t1Id, t2Id, score, false)
if (m.goals1?.length) await syncGoals(matchId, t1Id, m.goals1, t2Id)
if (m.goals2?.length) await syncGoals(matchId, t2Id, m.goals2, t1Id)
if (m.goals1?.length || m.goals2?.length) {
await db.execute(sql`DELETE FROM goals WHERE match_id = ${matchId}`)
if (m.goals1?.length) await syncGoals(matchId, t1Id, m.goals1, t2Id)
if (m.goals2?.length) await syncGoals(matchId, t2Id, m.goals2, t1Id)
}
matchCount++
goalCount += (m.goals1?.length ?? 0) + (m.goals2?.length ?? 0)
}