fix(npm-stats): stop summary cards overcounting co-installed packages#984
fix(npm-stats): stop summary cards overcounting co-installed packages#984tombeckenham wants to merge 1 commit into
Conversation
The NPM Stats summary cards (all-time, monthly, weekly, daily) summed every @tanstack/*start* package mapped to the library. ~9 of those are transitive deps of a single `@tanstack/react-start` install, so each install was counted ~9x (weekly showed 148.1M instead of ~16.5M). Make the cards honor the library's declared `npmPackageNames`, matching the chart below them: - NPMSummary uses the shared `recentDownloadsQuery` (which passes npmPackageNames) instead of a local copy that dropped it, fixing the daily/weekly/monthly cards. - `rebuildOssStatsCache` now restricts each library's aggregate to its declared `npmPackageNames` when present, fixing the all-time card. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
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 (2)
📝 WalkthroughWalkthroughTwo independent changes: ChangesNPMSummary query import cleanup
Explicit package allowlist filtering in rebuildOssStatsCache
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
KevinVandy
left a comment
There was a problem hiding this comment.
If we change the weekly number, wouldn't we have to change the monthly and daily numbers?
|
Let's have @tannerlinsley review the download number changes before this gets merged. I think I agree with the change, but this will be a quite visible change in how we've been displaying the download numbers. |
Problem
The NPM Stats summary cards (All-time, Monthly, Weekly, Daily) were inflated by ~9×. For TanStack Start, Weekly showed 148.1M when the real figure is ~16.5M.
Cause: the cards summed every
@tanstack/*start*package mapped to the library (43 of them). ~9 of those —start-client-core,start-server-core,start-plugin-core,react-start, etc. — are transitive dependencies of a single@tanstack/react-startinstall, so each install was counted ~9 times. The chart directly below the cards was already correct because it uses the library's declarednpmPackageNames.Fix
Make the summary cards honor
npmPackageNamestoo, so they match the chart:NPMSummarynow uses the sharedrecentDownloadsQuery(which passesnpmPackageNames) instead of a local copy that dropped it and fell back to the full registered-package set.rebuildOssStatsCachenow restricts each library's aggregate to its declarednpmPackageNameswhen present (libraries without an explicit list are unchanged).Testing
No DB required — the stats code falls back to live npm data when there's no cache. Run
pnpm dev, open/start/latest/docs/npm-stats: Weekly now shows ~16.5M (matching the chart) instead of 148.1M.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes