Skip to content

fix(events): paginate Dice.fm imports and window Ticketmaster geo queries - #4116

Draft
chubes4 wants to merge 1 commit into
mainfrom
fix/issue-4107-data-machine
Draft

chubes4 wants to merge 1 commit into
mainfrom
fix/issue-4107-data-machine

Conversation

@chubes4

@chubes4 chubes4 commented Nov 29, 2026

Copy link
Copy Markdown
Member

Summary

Dice imports now go through every page of results instead of only the first 100 events. The order is nearest-dated first, and a new default of 100 new events per run (max_items) keeps each run bounded. Ticketmaster geo queries with more than 1,000 events are split into date windows, so they are no longer cut off at 1,000. OPERATOR NOTE: the first Dice runs in big cities will work through a large backlog. London has about 5,300 events (54 pages) and New York about 950. Each Dice item goes through the AI step at roughly 14.6k tokens, so London takes about 53 runs at the default of 100 per run. Lower max_items on flow 807 if that cost is too high. The next few weeks of shows are filled first, and runs after the backlog only send new events downstream.

What changed

  • DiceFm::fetch_dice_fm_events follows links.next by incrementing page[number] until there is no next link. It stops at MAX_PAGES (80) and logs the warning 'DiceFm: Query exceeds pagination cap; events will be truncated'. If a later page fails, events from earlier pages are kept.
  • New Dice setting horizon_days (default 0 = no limit): paging stops once the date-sorted results go past the horizon, and an info line is logged.
  • Dice eligible events are sorted by start date (nearest first, ties keep their order) before the max_items limit is applied. Dice now has a default max_items of 100, which can be changed in DiceFmSettings. The country filter applies to events from every page.
  • The Dice log line for each eligible event is now at debug level instead of info, so a 5k-event run doesn't write 5k info lines.
  • Ticketmaster geo mode: when page 0 reports more than 1,000 events (totalElements), plan_date_windows splits the query into consecutive startDateTime/endDateTime windows, nearest first. Each window is checked with a size=1 request and halved, down to one day, until it fits. Spans grow again after sparse windows, with at most 12 windows. A window still over the cap logs the existing 'Query exceeds pagination cap' warning, now with the window's start and end times. Artist mode and queries under 1,000 events behave as before.
  • Tests: new DiceFmPaginationTest (7 tests with mocked HTTP: multi-page fetch, page cap plus warning, horizon, country filter across pages, nearest-first under max_items, default limit, failure on a later page). New TicketmasterGeoWindowTest (3 tests: query under 1,000 unchanged, 1,200 events split into windows with all of them reached, a single day still over the cap logs truncation). The existing truncation test now covers only artist mode.
  • docs/dice-fm-handler.md documents the pagination, the cap, the horizon and max_items.

Verification

  • 1-verify-b29aaf3049310ec7215cbba0ed4742121151ba4817f210d0658a1b0403c67969.txt (homeboy review lint data-machine-events --changed-since origin/main): passed on 0fedc30. Base main@eb1273e advanced to 3481b4f (base_behind_by: 7; rebase onto the current base before merging). 102987 ms; retained gate metadata.
  • repro: none (no repro gate was declared, so these gates do not prove the issue).
  • CI: pending

Cook run
  • Cook ID: agent-task-49fb75ee-aa52-42b7-8139-2eadcfb06268
  • Attempt run ID: agent-task-49fb75ee-aa52-42b7-8139-2eadcfb06268-attempt-1-ad49c8c8
  • Gate 1: tree 0b399bec398c2f79a515b9f053b8dcb8836f5e66

Delivery

Evidence

  • The npm build fails on main too, before PHPUnit runs: node_modules/leaflet.markercluster has no dist/MarkerCluster.css, so the EventsMap webpack build errors out. This is unrelated to this change.
  • homeboy review lint data-machine-events --changed-since origin/main: clean after the loop rewrite (exit 0).
  • homeboy review test (run locally with the broken npm prepare steps temporarily removed from homeboy.json, then restored) filtered to DiceFmPaginationTest|TicketmasterGeoWindowTest|TicketmasterHandlerTest: 66 passed, 0 failed. This run was before a small change in plan_date_windows that replaced a count()-based while loop with an equivalent for loop to satisfy lint; that change passed php -l and lint but its tests were not re-run.

AI disclosure

Tool: Homeboy Cook. Agent: Homeboy (roadie). Model: roadie · route cook-heavy · served claude-opus-5-5. Cook time: 1h15m.

Implementation and reviewer documentation were written by the AI, under the direction of the Cook requester. Gates were run by Homeboy. A human reviews before merge.

Refs #4107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant