Conversation
We were fetching the whole packument which is _pretty big_. So this switches to using fast-npm-meta which is basically just trimmed down metadata.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughUpdated package metadata retrieval in the timeline sizes API endpoint from Changes
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
server/api/registry/timeline/sizes/[...pkg].get.ts (1)
46-48: Precompute publish timestamps before sorting.
Date.parseis currently executed repeatedly during sort comparisons. For large version lists, precomputing once per version is cheaper and removes the need for non-null assertions.♻️ Proposed refactor
- const allVersions = versions - .filter(v => time[v]) - .sort((a, b) => Date.parse(time[b]!) - Date.parse(time[a]!)) + const allVersions = versions + .map(version => ({ + version, + publishedTs: Date.parse(time[version] ?? ''), + })) + .filter(item => Number.isFinite(item.publishedTs)) + .sort((a, b) => b.publishedTs - a.publishedTs) + .map(item => item.version)As per coding guidelines, "Follow standard TypeScript conventions and best practices" and "Ensure you write strictly type-safe code".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@server/api/registry/timeline/sizes/`[...pkg].get.ts around lines 46 - 48, The sort repeatedly calls Date.parse and uses non-null assertions on time entries; precompute a numeric timestamp map for each version from versions and use that map when filtering and sorting (replace the inline Date.parse(time[...]) calls), then sort by the numeric timestamps (e.g., compare tsMap[b] - tsMap[a]) and remove the non-null assertions—update the code that builds allVersions (and any uses of time within that scope) to reference the precomputed tsMap for type-safe, single-parse sorting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@server/api/registry/timeline/sizes/`[...pkg].get.ts:
- Around line 46-48: The sort repeatedly calls Date.parse and uses non-null
assertions on time entries; precompute a numeric timestamp map for each version
from versions and use that map when filtering and sorting (replace the inline
Date.parse(time[...]) calls), then sort by the numeric timestamps (e.g., compare
tsMap[b] - tsMap[a]) and remove the non-null assertions—update the code that
builds allVersions (and any uses of time within that scope) to reference the
precomputed tsMap for type-safe, single-parse sorting.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 23554948-7402-4426-8818-2b42739ab8cf
📒 Files selected for processing (1)
server/api/registry/timeline/sizes/[...pkg].get.ts
🔗 Linked issue
N/A
🧭 Context
Timeline is currently awfully slow for packages with a large amount of versions.
📚 Description
We were fetching the whole packument which is pretty big.
So this switches to using fast-npm-meta which is basically just
trimmed down metadata.