mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-11 01:26:37 +00:00
perf(sports): fetch ESPN date chunks concurrently
Since ESPN started rejecting `dates=YYYYMMDD-YYYYMMDD` on 2026-09-15, one season request became a chunk per month -- and a month over the 500-event cap becomes a request per day. A cold college-baseball season is about 130 requests, and they went out one at a time. That is slower than the 20s budget `_update_plugins()` shares across every plugin at startup, so scoreboards were logging `update() timed out` on first run and being deferred to the scheduled tick with nothing on the panel. Measured on a Pi 4 against live ESPN, March+April college baseball (63 requests, 3101 events): 11.2s sequential, 1.6s concurrent. Over a whole boot that moved football-scoreboard, ledmatrix-flights and birdnet-go inside the budget -- 13 plugins deferred before, 10 after. Chunks now go out six at a time, in two passes: months and edge days first, then the days of any month that came back capped. Six keeps the shared Session under requests' default pool_maxsize of 10, so no connection is discarded. Merged events still follow `espn_date_chunks` order -- a capped month's days are spliced back into its own slot -- so the payload does not depend on which request won the race. Request order is no longer significant, so the three tests that pinned it compare the chunks as a set and keep asserting the merged event order, which is the part callers actually see. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -115,8 +115,11 @@ def test_a_rejected_season_is_recovered_and_cached(service, cache):
|
||||
def test_a_full_season_costs_chunks_not_one_request_per_day(service):
|
||||
session = RangeRejectingSession({"202609": [{"id": "a"}]})
|
||||
submit_and_wait(service, session, "20260801-20270301")
|
||||
assert [call["dates"] for call in session.calls] == [
|
||||
"20260801-20270301",
|
||||
sent = [call["dates"] for call in session.calls]
|
||||
# Eight chunks rather than 213 per-day requests. They are fetched
|
||||
# concurrently, so the range is the only one pinned to a position.
|
||||
assert sent[0] == "20260801-20270301"
|
||||
assert sorted(sent[1:]) == [
|
||||
"202608",
|
||||
"202609",
|
||||
"202610",
|
||||
|
||||
Reference in New Issue
Block a user