Repository navigation
fix(ccusage): sort session reports by cost instead of last activity - #907
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)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughloadSessionData now sorts aggregated sessions by totalCost (desc by default; use options.order = 'asc' for ascending). Implementation switched to ChangesSession sorting logic
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 |
# Conflicts: # apps/ccusage/src/data-loader.ts
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