Premier League Predictor: FastAPI & Redis — Chapter 12, Exercise 3 ================================================================== TASK Import a full 380-result season through the Chapter 7 script, snapshot the sorted set and every team's stats hash, import the same 380 results again, and snapshot again. Report whether the two snapshots are identical and what that means for a backfill that gets interrupted and re-run. SOLUTION for each of 380 (fixture, home, away, home_score, away_score): apply_result(keys=[fixture, fixture:applied, season:9:table, season:9:team:{h}:stats, season:9:team:{a}:stats], args=[member_h, member_a, home_score, away_score]) snapshot = (ZRANGE season:9:table 0 -1 WITHSCORES, HGETALL of all 20 season:9:team:{id}:stats) first import == second import (whole snapshot): True played per team after either import: {'38'} (every team, both times) The second pass changed nothing. Each fixture's :applied hash records the result last applied, so the script reverses that result and applies the same one again, ending exactly where it started. Nothing is double-counted and no field is left at a different value. Consequence for a backfill: it can be interrupted at any point and simply started again from the beginning, or from any earlier point, without first working out what was already imported. The only requirement is that every route into the table goes through the script; results written some other way are invisible to the :applied bookkeeping. WHY THIS WORKS AS AN ANSWER ---------------------------- It compares the whole state, not just a summary, and connects the result to the practical property that matters: a re-runnable import.