Skip to content

feat(markets): materialize market odds snapshot for live odds broadcast (#1502) - #2088

Open
huangji6693-max wants to merge 1 commit into
Arena1X:mainfrom
huangji6693-max:feat/materialized-market-odds-snapshot-1502
Open

huangji6693-max wants to merge 1 commit into
Arena1X:mainfrom
huangji6693-max:feat/materialized-market-odds-snapshot-1502

Conversation

@huangji6693-max

Copy link
Copy Markdown

Closes #1502

Summary

  • Added CACHE_WARMING_KEYS.marketOddsSnapshot(marketId) in backend/src/cache/cache-warming.keys.ts.
  • Updated OddsBroadcasterService (backend/src/websocket/odds-broadcaster.service.ts) to maintain materialized per-market odds snapshots (getSnapshot, setSnapshot, applyPredictionIncrement, reconcileSnapshot, broadcastFromSnapshot) so live broadcasts read directly from the materialized snapshot without querying the database on each broadcast.
  • Updated MarketsService (backend/src/markets/markets.service.ts) with getOddsSnapshot, recordPredictionOddsWrite, reconcileOddsSnapshot, and warmMarketOddsSnapshots so incremental prediction writes update the snapshot in place and full replacement only happens on reconciliation or cache warming.
  • Exposed GET /public/markets/:id/odds in PublicMarketsController (backend/src/markets/public-markets.controller.ts) so initial page loads and WebSocket updates share the exact same materialized source of truth.
  • Added unit tests in odds-broadcaster.service.spec.ts, markets.service.spec.ts, and public-markets.controller.spec.ts verifying incremental updates match brute-force recompute.

Verification

  • npx jest src/websocket/odds-broadcaster.service.spec.ts src/markets/markets.service.spec.ts src/markets/public-markets.controller.spec.ts (3/3 test suites passed, 67/67 tests passed)

@vercel

vercel Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
insight-arena-4rll Error Error Oct 26, 2026 6:25pm UTC

This branch had an error being deployed

1 failed deployment
Preview — 8ce8a462 Deployed Oct 26, 2026 by vercel[bot]
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.

[Backend] — Materialized Market Odds Snapshot for Live Odds Broadcast

1 participant