Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add trends tab #77

Merged
merged 1 commit into from
Mar 29, 2024
Merged

feat: add trends tab #77

merged 1 commit into from
Mar 29, 2024

Conversation

elrrrrrrr
Copy link
Member

@elrrrrrrr elrrrrrrr commented Mar 28, 2024

参照 https://npmtrends.com/next 实现下载趋势对比, see #75

  1. 默认全量展示 2020 年开始相关数据
  2. 支持最多5个包横向对比

image

Summary by CodeRabbit

  • New Features
    • Introduced a "Download Trends" tab to provide insights into the download trends of packages.
    • Added a new Trends component that allows users to view and compare the total downloads of multiple packages over different years.
    • Implemented functionality to search for packages and display their total download statistics on the Trends page.

@elrrrrrrr elrrrrrrr added the enhancement New feature or request label Mar 28, 2024
Copy link

coderabbitai bot commented Mar 28, 2024

Walkthrough

The recent update introduces a new feature focused on "Download Trends", enhancing the application's ability to display and analyze the download trends of multiple packages. This feature includes the addition of a new tab, components, and hooks to fetch, aggregate, and present total download data. It also introduces a new page component dedicated to showcasing these trends, alongside a sophisticated UI for selecting and viewing the packages' download statistics.

Changes

Files Change Summaries
src/components/CustomTabs.tsx Added a new tab for "下载趋势" (Download Trends).
src/components/RecentDownloads.tsx, src/hooks/useRecentDownloads.ts Enhanced to support total downloads display and fetching, including new components and hooks.
src/pages/package/[...slug]/index.tsx, src/slugs/trends/index.tsx Added components and logic for displaying package download trends and user interactions.

🐰✨
In the realm of bytes and bits, a new feature alights,
"Download Trends" it's called, amidst digital heights.
📉📈 For numbers that dance, in the moon's gentle beams,
A rabbit hops forth, chasing data streams.
🌟 With each line of code, a story it weaves,
In this digital burrow, where magic breathes.
🚀 To the stars, our creations we send,
Guided by paws, on trends they ascend.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

vercel bot commented Mar 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cnpmweb ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 28, 2024 3:58pm

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 909a82c and 2e34f7a.
Files selected for processing (5)
  • src/components/CustomTabs.tsx (1 hunks)
  • src/components/RecentDownloads.tsx (2 hunks)
  • src/hooks/useRecentDownloads.ts (3 hunks)
  • src/pages/package/[...slug]/index.tsx (2 hunks)
  • src/slugs/trends/index.tsx (1 hunks)
Additional comments (5)
src/components/CustomTabs.tsx (1)
  • 25-28: The addition of the "下载趋势" (Download Trends) tab is correctly implemented and follows the existing pattern in the presetTabs array. Two considerations:
  1. Ensure the key 'trends' is unique across the application to avoid potential conflicts.
  2. Consider internationalization (i18n) for the hardcoded Chinese string to support multiple languages in the future.
src/slugs/trends/index.tsx (1)
  • 1-60: The implementation of the Trends component is well-structured and follows React best practices. Considerations for improvement:
  1. Add error handling for the search functionality to gracefully handle potential issues.
  2. Ensure the UI accounts for loading states and potential errors from the useTotalDownloads hook, providing a better user experience during data fetching.
src/hooks/useRecentDownloads.ts (1)
  • 21-39: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [6-72]

The additions of INIT_YEAR, getTotalUrl, and useTotalDownloads are well-implemented and follow best practices. Considerations for improvement:

  1. Reevaluate the maintainability of the hardcoded INIT_YEAR constant for future years.
  2. Implement error handling in the useTotalDownloads hook to gracefully handle fetch failures and improve the user experience.
src/pages/package/[...slug]/index.tsx (1)
  • 69-69: The addition of PageTrends to the PageMap object is correctly implemented, enabling routing to the new trends page. Considerations:
  1. Verify the routing functionality to ensure it works as expected.
  2. Thoroughly test the PageTrends component, focusing on routing and data fetching.
src/components/RecentDownloads.tsx (1)
  • 63-145: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-145]

The implementation of the TotalDownloads component is well-structured and effectively utilizes the useTotalDownloads hook for data fetching. Considerations for improvement:

  1. Explore more scalable solutions for managing package names and data fetching, beyond the fixed array approach, to enhance maintainability and flexibility.
  2. Ensure that error handling and loading states are gracefully managed to provide a better user experience during data fetching.

Copy link
Member

@fengmk2 fengmk2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@fengmk2
Copy link
Member

fengmk2 commented Mar 29, 2024

npm cli 已经被超越

@fengmk2 fengmk2 merged commit cd8ccb7 into main Mar 29, 2024
6 checks passed
@fengmk2 fengmk2 deleted the trends branch March 29, 2024 02:10
@fengmk2
Copy link
Member

fengmk2 commented Mar 29, 2024

@elrrrrrrr 啊,我测试了一下,对比 url 不会变化?没法将当前对比结果链接分享出去。

@elrrrrrrr
Copy link
Member Author

@elrrrrrrr 啊,我测试了一下,对比 url 不会变化?没法将当前对比结果链接分享出去。

😄 我一会儿加下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants