Repository navigation
fix(analytics): Optimize pricing query handling - #1254
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 15 minutes. View limit details
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 |
OpenAPI changes ⚪ No API surface changesNote This PR does not modify the API contract.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
🎉 This PR is included in version 1.8.0-main.5 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Issue
Closes #1255
Summary
Bug: analytics API (
GET /analytics/monthly/chartand/analytics/monthly) ran a separate database query to fetch model pricing for every row in the result. One request was making ~98 extra queries (N+1), which Sentry flagged.Fix: all the needed model pricing is now fetched in a single query, and the cost for each row is calculated in memory. The number of queries no longer grows with the number of rows.
Checklist
Before submitting a pull request, please ensure that you mark these task.
fastapi run --reload app/main.pyordocker compose upin the repository root and test.Note: