Premier League Predictor: FastAPI & PostgreSQL — Chapter 7, Exercise 3 ==================================================== TASK Enter real results for at least three fixtures in a real season (some involving the same team as both home and away across different gameweeks), call GET /api/seasons/{id}/table, and confirm by hand that at least one team's played/won/drawn/lost/points figures correctly combine both its home and away results. SOLUTION Using a real season with Team A appearing in two different fixtures — once at home, once away — plus a third unrelated fixture: 1. Gameweek 1: Team A (home) 2-1 Team B (away) — PATCH the result via /api/fixtures/{id}/result. 2. Gameweek 2: Team C (home) 0-0 Team A (away) — PATCH this result too. 3. Gameweek 2: Team D (home) 1-3 Team E (away) — a third, unrelated result, entered just to confirm the table handles more than one team correctly at once. By hand, Team A's real combined record across its two fixtures: - Fixture 1 (home): won 2-1 → 1 win, goals_for 2, goals_against 1, 3 points. - Fixture 2 (away): drew 0-0 → 1 draw, goals_for 0, goals_against 0, 1 point. - Combined: played 2, won 1, drawn 1, lost 0, goals_for 2, goals_against 1, goal_difference +1, points 4. Calling GET /api/seasons/{id}/table and finding Team A's row should show exactly played: 2, won: 1, drawn: 1, lost: 0, goals_for: 2, goals_against: 1, goal_difference: 1, points: 4 — matching the by-hand calculation exactly, with the away 0-0 draw correctly folded in alongside the home win rather than only one of the two fixtures being counted. Team D and Team E's rows should independently show Team D with 1 played, 0 won, 0 drawn, 1 lost, goals_for 1, goals_against 3, goal difference -2, 0 points; and Team E with 1 played, 1 won, 0 drawn, 0 lost, goals_for 3, goals_against 1, goal difference +2, 3 points — confirming the query correctly separates each team's own record rather than mixing fixtures together. WHY THIS WORKS AS AN ANSWER ---------------------------- It deliberately constructs a scenario where the same team plays once at home and once away, computes that team's real combined record by hand first, then verifies the query's actual response matches that hand-calculated result exactly — directly testing the UNION ALL normalization from Exercise 1 rather than just trusting it works.