Repository navigation
v2.1.6 — Phase 9.10 sync pipeline helpers
Phase 9.10 — Sync pipeline helpers extraction
Seven god-class methods leave `dataflair-toplists.php` for dedicated single-responsibility classes under `src/Sync/` and `src/Database/`.
New classes
- Sync/EndpointDiscovery — walks `/toplists?per_page=15&page=N` via `meta.last_page`, returns show-endpoint URLs.
- Sync/ToplistFetcher — GET → JSON parse → `data.id` guard pipeline; delegates persist to `ToplistDataStore`.
- Database/ToplistDataStore — `wp_dataflair_toplists` upsert with integrity validation, ten-column row map, `api_toplist_id` upsert key.
- Sync/TransientCleaner (Phase 0B H10) — chunked DELETE at 1,000 rows/statement across both `transient_dataflair_tracker%` patterns. Optional `WallClockBudget` bail-out.
- Database/PaginatedDeleter (Phase 0B H11) — whitelist-enforced chunked DELETE at clamped 50–5,000 rows/chunk. Replaces `TRUNCATE TABLE` (not safely replicable on managed-MySQL hosts).
- Database/JsonValueCollector — column-whitelisted DISTINCT collector for CSV columns (`licenses`, `top_geos`, `product_types`).
- Sync/LogoSync — sync-side facade onto `Http\LogoDownloader`.
Main file trim
`dataflair-toplists.php`: 1,939 → 1,772 LOC (−167). Seven god-class methods become one-line delegators wired through lazy `Container` getters. Closure-based DI keeps still-private god-class helpers wired without breaking the strangler-fig contract — both extract to `Http/` classes in v2.1.7.
Invariants preserved
- Phase 0B H10 chunked transient sweep (`LIMIT 1000`).
- Phase 0B H11 paginated DELETE replacing TRUNCATE.
- `WallClockBudget` cooperative bail-out before the first query.
- Render-time read-only invariant (`RenderIsReadOnlyTest` still green).
- No public contract change: byte-identical side effects on `error_log` / `add_settings_error`.
Tests
25 new unit tests pin happy-path delegation, error short-circuits, JSON parse failure, missing-id rejection, insert vs update path selection, `$wpdb` error propagation, chunk clamping, whitelist enforcement, pagination via `meta.last_page`, and budget bail-out.
Full suite: 503 tests, 1,151 assertions, all green (+25 new).