Skip to content

Conversation

@Romakita
Copy link
Contributor

@Romakita Romakita commented May 19, 2025

Summary by CodeRabbit

  • New Features

    • Added dynamic calculation and display of total downloads and unique maintainers in the warehouse statistics.
    • Introduced filtering of packages by maintainer, allowing users to view packages by specific authors.
    • Enhanced statistics section to update in real-time based on the current data.
  • Improvements

    • Added loading state indicators to statistics cards for clearer feedback during data fetches.
    • Updated banner section to support flexible content via slots.
  • Documentation

    • Improved Storybook stories for the Warehouse component, including customizable slot content.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 19, 2025

Walkthrough

The updates introduce dynamic calculation and display of package warehouse statistics, including total downloads and maintainers, by enhancing the useWarehouse composable and updating related UI components. Filtering by maintainer is added, and loading state logic is incorporated into the stats card. Storybook stories gain a custom render function and updated args, and coverage thresholds are slightly lowered.

Changes

File(s) Change Summary
packages/theme/composables/api/useWarehouse.ts Added reactive downloads and maintainers references; updated fetchPackages to accumulate these values and return them.
packages/theme/molecules/card-stats/CardStats.vue Added optional isLoading prop; updated display logic to show hyphen when loading or value is falsy.
packages/theme/organisms/warehouse/Warehouse.vue Replaced static stats with computed values, added maintainer filter and reactive author filter, updated UI to use new stats, filters, and slot for banner content.
packages/theme/organisms/warehouse/Warehouse.stories.ts Added custom render function, updated story args to include text, imported unused Button component, removed two text assertions in play function.
vitest.config.ts Lowered coverage thresholds for statements and lines by ~1%.

Sequence Diagram(s)

sequenceDiagram
  participant UI (Warehouse.vue)
  participant useWarehouse
  participant API

  UI->>useWarehouse: fetchPackages()
  useWarehouse->>API: Fetch package data
  API-->>useWarehouse: Return package list
  useWarehouse->>useWarehouse: Calculate downloads, maintainers
  useWarehouse-->>UI: Return packages, downloads, maintainers, etc.
  UI->>UI: Compute stats, authors list
  UI->>UI: Render CardStats and FilterBy with dynamic data
Loading

Poem

🐇
In the warehouse, numbers grow,
Maintainers join, downloads flow.
Filters help you find your friend,
Stats now update, never pretend.
With loading states and stories new,
The code hops forward—onward, through!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 9bb5499 and 7fa0f0f.

📒 Files selected for processing (5)
  • packages/theme/composables/api/useWarehouse.ts (2 hunks)
  • packages/theme/molecules/card-stats/CardStats.vue (2 hunks)
  • packages/theme/organisms/warehouse/Warehouse.stories.ts (2 hunks)
  • packages/theme/organisms/warehouse/Warehouse.vue (4 hunks)
  • vitest.config.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • vitest.config.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/theme/organisms/warehouse/Warehouse.stories.ts
  • packages/theme/molecules/card-stats/CardStats.vue
  • packages/theme/composables/api/useWarehouse.ts
  • packages/theme/organisms/warehouse/Warehouse.vue
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: lint
  • GitHub Check: build
  • GitHub Check: test
  • GitHub Check: chromatic
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Romakita Romakita force-pushed the fix-warehouse-statistics branch from 396e67c to 9bb5499 Compare May 19, 2025 08:33
Copy link
Contributor

@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.

Actionable comments posted: 0

🧹 Nitpick comments (7)
packages/theme/composables/api/useWarehouse.ts (1)

22-23: Consider initializing downloads to 0

The initial value of 20000 for downloads seems arbitrary and could be misleading if displayed before data is fetched. Since you're resetting it to 0 in the fetchPackages function anyway, consider initializing it to 0 for consistency.

-  const downloads = ref<number>(20000);
+  const downloads = ref<number>(0);
vitest.config.ts (1)

22-25: Consider adding tests for new functionality

The coverage thresholds for statements and lines have been lowered from 59.72% to 58.73%. While this is a common practice when adding new features, consider adding tests for the new functionality to maintain or improve coverage.

packages/theme/molecules/card-stats/CardStats.vue (2)

7-7: Add default value for isLoading prop

You've added an optional isLoading prop, but there's no default value specified in the withDefaults call. Consider adding a default value to ensure consistent behavior.

const props = withDefaults(defineProps<WarehouseStatsProps>(), {
  id: "card-stats-item",
  items: () => [],
+  isLoading: false
});

20-20: Consider making the condition more explicit

The conditional logic works correctly but could be more explicit by separating the null/undefined check from the loading check.

-      value: item.value && !props.isLoading ? formatNumber(item.value) : "-"
+      value: (item.value && !props.isLoading) ? formatNumber(item.value) : "-"

Alternatively, for even better readability:

-      value: item.value && !props.isLoading ? formatNumber(item.value) : "-"
+      value: (!props.isLoading && item.value) ? formatNumber(item.value) : "-"
packages/theme/organisms/warehouse/Warehouse.stories.ts (2)

5-5: Remove unused import

The Button component is imported but not used in this file. Consider removing it to keep the code clean.

-import Button from "../../molecules/button/Button.vue";

28-30: Avoid using 'as any' type assertion

Type assertions with 'as any' should be avoided when possible as they bypass TypeScript's type checking. Consider defining proper types for the args.

-  args: {
-    text: 'Discover our list of plugins to extend your Ts.ED project. Created by the Ts.ED team and community.'
-  } as any,
+  args: {
+    text: 'Discover our list of plugins to extend your Ts.ED project. Created by the Ts.ED team and community.'
+  },
packages/theme/organisms/warehouse/Warehouse.vue (1)

80-92: Good implementation of author filtering.

The implementation of the author filter follows the same pattern as other filters in the component, making it consistent and maintainable.

Consider simplifying the concat operation slightly:

-  return [{
-    label: "All",
-    value: ""
-  }].concat([...maintainers.value.values()]
-      .map((maintainer) => {
-        return {
-          label: maintainer,
-          value: maintainer
-        };
-      }));
+  return [
+    {
+      label: "All",
+      value: ""
+    },
+    ...[...maintainers.value.values()].map((maintainer) => ({
+      label: maintainer,
+      value: maintainer
+    }))
+  ];
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 940ff09 and 9bb5499.

📒 Files selected for processing (5)
  • packages/theme/composables/api/useWarehouse.ts (2 hunks)
  • packages/theme/molecules/card-stats/CardStats.vue (2 hunks)
  • packages/theme/organisms/warehouse/Warehouse.stories.ts (2 hunks)
  • packages/theme/organisms/warehouse/Warehouse.vue (4 hunks)
  • vitest.config.ts (1 hunks)
🔇 Additional comments (9)
packages/theme/composables/api/useWarehouse.ts (2)

34-43: LGTM! Good implementation for stats calculation

The implementation correctly resets the download counter and maintainers set before processing new data. The download count accumulation and collection of maintainer usernames (with lowercase conversion for case-insensitivity) are well implemented.


58-58: LGTM! Properly exposing new reactive references

The new reactive references (maintainers and downloads) are correctly included in the returned object from the composable.

packages/theme/organisms/warehouse/Warehouse.stories.ts (1)

15-21: LGTM! Clean implementation of custom render function

The custom render function is well implemented, properly binding args to the component and using args.text as slot content.

packages/theme/organisms/warehouse/Warehouse.vue (6)

18-18: Good enhancement to useWarehouse destructuring.

The destructuring now includes maintainers and downloads which will enable the dynamic statistics calculation that follows.


62-77: Well implemented reactive stats.

Converting the static stats array to a computed property is a good approach, as it allows the statistics to update dynamically based on the reactive state. This follows Vue's best practices for derived state.


100-102: Effective author matching implementation.

The author filtering logic is well-implemented, matching against maintainer usernames while properly handling the case when no author is selected.


128-128: Good use of slots for flexible content.

Replacing the fixed banner content with a slot makes the component more flexible and reusable.


134-134: Proper loading state integration.

Passing the isActive state to the CardStats component as a loading indicator ensures a consistent user experience during data fetching.


171-171: Good UI addition for author filtering.

The new FilterBy component for authors follows the same pattern as the existing filtering controls, maintaining UI consistency.

@Romakita Romakita force-pushed the fix-warehouse-statistics branch from 9bb5499 to 7fa0f0f Compare May 19, 2025 08:40
@Romakita Romakita merged commit f1b7a92 into main May 19, 2025
10 of 12 checks passed
@Romakita Romakita deleted the fix-warehouse-statistics branch May 19, 2025 08:44
@Romakita
Copy link
Contributor Author

🎉 This PR is included in version 1.5.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants