fix: also clean up stale knockout matches when date changes on Wikipedia

The previous fix only removed stale entries when the team pairing changed.
It missed the case where Wikipedia updates the date/time for the same teams
(same pair, different date = different upsert key). Now any knockout match
with the same year+round involving either team is deleted unless it is the
exact same pairing AND date.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-04 11:25:29 +02:00
co-authored by Claude Sonnet 4.6
parent 36f324e53f
commit 20c6b5545c
+8 -4
View File
@@ -51,8 +51,10 @@ async function run() {
AND group_name IS NULL
AND is_quali_playoff = ${isQuali}
AND (team1_id = ${team1Id} OR team2_id = ${team1Id} OR team1_id = ${team2Id} OR team2_id = ${team2Id})
AND NOT (team1_id = ${team1Id} AND team2_id = ${team2Id})
AND NOT (team1_id = ${team2Id} AND team2_id = ${team1Id})
AND NOT (
(team1_id = ${team1Id} AND team2_id = ${team2Id} AND date IS NOT DISTINCT FROM ${dateStr})
OR (team1_id = ${team2Id} AND team2_id = ${team1Id} AND date IS NOT DISTINCT FROM ${dateStr})
)
)
`)
await db.execute(sql`
@@ -62,8 +64,10 @@ async function run() {
AND group_name IS NULL
AND is_quali_playoff = ${isQuali}
AND (team1_id = ${team1Id} OR team2_id = ${team1Id} OR team1_id = ${team2Id} OR team2_id = ${team2Id})
AND NOT (team1_id = ${team1Id} AND team2_id = ${team2Id})
AND NOT (team1_id = ${team2Id} AND team2_id = ${team1Id})
AND NOT (
(team1_id = ${team1Id} AND team2_id = ${team2Id} AND date IS NOT DISTINCT FROM ${dateStr})
OR (team1_id = ${team2Id} AND team2_id = ${team1Id} AND date IS NOT DISTINCT FROM ${dateStr})
)
`)
}