fix(ccusage): sort session reports by cost instead of last activity#907
fix(ccusage): sort session reports by cost instead of last activity#907bluzername wants to merge 1 commit intoryoppippi:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughSession data sorting behavior has been refactored to prioritize cost instead of last activity. The Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
Problem
The Session Reports documentation says:
But actually running
pnpx ccusage sessionshows entries sorted by Last Activity timestamp instead of by Cost. This was confusing because the expensive sessions were not at the top like I was expecting.What I changed
In
apps/ccusage/src/data-loader.ts, theloadSessionDatafunction was usingsortByDateonlastActivityfield:Changed to sort by
totalCostusingfast-sortdirectly:Also updated:
costUSDvalues per session so they actually verify sorting by cost and not just any orderTesting
pnpm run formatpassescostUSD: 0.01,0.05,0.10to verify cost ordering works correctCloses #903
Summary by CodeRabbit