fix: replace stale activity cards with live alerts - #8
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe change centralizes Polymarket activity queries, updates activity filtering and cache expiry, detects odds changes between live snapshots, and refreshes stale conflict feeds immediately. ChangesConflict activity flow
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant ConflictMapPreview
participant ActivityRail
participant GlobalConflictActivityRoute
participant PolymarketTradesAPI
ConflictMapPreview->>ActivityRail: provide refreshed live feed snapshot
ActivityRail->>ActivityRail: compare current and previous snapshots
ActivityRail->>GlobalConflictActivityRoute: request activity for valid event IDs
GlobalConflictActivityRoute->>PolymarketTradesAPI: query bounded trade activity
PolymarketTradesAPI-->>GlobalConflictActivityRoute: return matching trades
GlobalConflictActivityRoute-->>ActivityRail: return activity items
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 835ec70750
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const previousEvent = previousEvents.get(event.id); | ||
| if (!previousEvent) continue; | ||
| const change = event.yesOdds - previousEvent.yesOdds; |
There was a problem hiding this comment.
Verify the selected market before comparing odds
When a Gamma event contains multiple markets, normalizeConflictPreviewEvent can retain the same aggregate polymarket-${event.id} while selecting a different market because volume ordering changes or the previous market closes. Looking up the baseline only by that aggregate ID then subtracts odds belonging to different questions, producing a misleading live odds alert. Preserve a market-level identifier in the feed or otherwise confirm the selected market is unchanged before calculating the difference.
Useful? React with 👍 / 👎.
| const baseline = previousFeed.current; | ||
| previousFeed.current = feed; |
There was a problem hiding this comment.
Keep the newest snapshot as the comparison baseline
When the browser or CDN's stale-while-revalidate cache returns an older live payload after a newer SSR or client payload, this assignment replaces the baseline even though snapshotMoverNotices rejects the out-of-order timestamp. The next fresh response is consequently compared with the older odds and can re-emit an already observed or cumulative change as happening now. Only advance the stored baseline when the incoming updatedAt is newer.
Useful? React with 👍 / 👎.
Summary
nowactivity cardsVerification
npm run checknpm run test:e2e— 21 passednpm audit --audit-level=moderate— 0 vulnerabilitiesSummary by CodeRabbit
New Features
Bug Fixes
Tests