Skip to content

added the platform parameter and changed to activityType#107

Closed
emlimlf wants to merge 0 commit intomainfrom
improvement/pass-activity-platform
Closed

added the platform parameter and changed to activityType#107
emlimlf wants to merge 0 commit intomainfrom
improvement/pass-activity-platform

Conversation

@emlimlf
Copy link
Copy Markdown
Collaborator

@emlimlf emlimlf commented Mar 17, 2025

In this PR

  • Handled the platform in the dropdown select
  • Added the platform parameter to the api call for contributor leaderboard, contributor dependency, org leaderboard, org dependency and geo distribution widgets
  • rename the metric parameter to activityType

Summary by CodeRabbit

  • New Features
    • Enhanced contributions and organizations views with a more granular metric breakdown that distinguishes between platform and activity type.
    • Updated filtering options and table headers to reflect the refined metrics, offering users clearer data categorization.
    • Adjusted the data fetching logic to support these improvements, resulting in more specific and accurate query results.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 17, 2025

Walkthrough

The pull request updates several components to change the handling of the metric state. The metric value is modified from "all" to "all:all", and computed properties are introduced to split this string into platform and activityType. Components using API calls now pass these two separate parameters rather than a single metric value. Additionally, table header conditions have been updated to use the revised metric format, and the structure of metric dropdown options has been transformed using a mapping function with improved type safety.

Changes

File(s) Change Summary
frontend/app/components/modules/project/components/contributors/{contributor-dependency.vue, contributors-leaderboard.vue, organization-dependency.vue, organizations-leaderboard.vue, geographical-distribution.vue} Updated the metric variable from 'all' to 'all:all', added computed properties (platform and activityType), and modified API fetch calls to use these separate parameters.
frontend/app/components/modules/project/components/contributors/fragments/{contributors-table.vue, organizations-table.vue} Adjusted header logic by replacing conditions that checked for 'all' with 'all:all' and used the split metric value for label lookups.
frontend/app/components/modules/project/components/contributors/fragments/metric-dropdown.vue Transformed metricOptions using a mapping function to create structured dropdown items and added an import for the DropdownGroupOptions type.

Sequence Diagram(s)

sequenceDiagram
    participant Component
    participant ComputedProps
    participant API

    Component->>ComputedProps: Read metric ("all:all")
    ComputedProps-->>Component: Return platform & activityType
    Component->>API: Call useFetch(platform, activityType)
Loading

Possibly related PRs

  • Add Contributor Dependency widget endpoint #84: The changes in the main PR and the retrieved PR are related as both modify the metric variable to use the value 'all:all' and introduce computed properties for platform and activityType, affecting how data is fetched and processed in their respective components.
  • fix all api params reactive issue #88: The changes in the main PR and the retrieved PR are related as both modify the metric variable and its usage in the useFetch function, specifically transitioning from accessing metric.value to using metric directly, while also introducing computed properties for platform and activityType in the main PR.
  • Collections adjustments #61: The changes in the main PR and the retrieved PR both involve modifications to the metric variable, specifically updating its value to 'all:all' and introducing computed properties for platform and activityType, indicating a direct relationship at the code level.

Suggested reviewers

  • gaspergrom
  • borfast

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97578559907f5cabb710c60e1395d7fa6a2ce997 and bf6f97946e7171443080be566facc29733442167.

📒 Files selected for processing (2)
  • frontend/app/components/modules/project/components/contributors/fragments/contributors-table.vue (1 hunks)
  • frontend/app/components/modules/project/components/contributors/fragments/organizations-table.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/app/components/modules/project/components/contributors/fragments/organizations-table.vue
  • frontend/app/components/modules/project/components/contributors/fragments/contributors-table.vue

🪧 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.
    • Generate unit testing code 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 testing code 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 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 generate unit testing code.
    • @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.

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

@emlimlf emlimlf requested a review from borfast March 17, 2025 11:10
Copy link
Copy Markdown

@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: 1

🧹 Nitpick comments (4)
frontend/app/components/modules/project/components/contributors/contributor-dependency.vue (1)

77-79: Update to metric format and introduction of platform parameter

The code now uses a combined format for metrics ('all:all') and splits it into platform and activityType components. This change supports the new parameter structure in the API while maintaining backward compatibility with the UI components.

Consider adding error handling in case the metric string doesn't contain a colon character. For example:

-const platform = computed(() => metric.value.split(':')[0]);
-const activityType = computed(() => metric.value.split(':')[1]);
+const platform = computed(() => {
+  const parts = metric.value.split(':');
+  return parts.length > 0 ? parts[0] : 'all';
+});
+const activityType = computed(() => {
+  const parts = metric.value.split(':');
+  return parts.length > 1 ? parts[1] : 'all';
+});
frontend/app/components/modules/project/components/contributors/organization-dependency.vue (1)

77-79: Update to metric format and introduction of platform parameter

Same changes as in contributor-dependency.vue - the metric format is now 'all:all' and computed properties have been added to split it into platform and activityType parameters.

Consider adding error handling for malformed metric strings, as mentioned in the previous file.

frontend/app/components/modules/project/components/contributors/organizations-leaderboard.vue (1)

51-53: Update to metric format and introduction of platform parameter

The metric format has been updated to 'all:all' with computed properties to extract platform and activityType values. This change is consistent with other files in this PR.

The same recommendation for error handling applies here too.

frontend/app/components/modules/project/components/contributors/contributors-leaderboard.vue (1)

50-53: Update to metric format and introduction of platform parameter

The metric format has been updated to 'all:all' with computed properties to extract platform and activityType values, consistent with the other files in this PR.

The same suggestion for error handling applies here as well.

Note: There's an extra empty line (53) that could be removed for consistency.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1f3efe and 93e206d338e77c94e6f8fca192676d63b11726e7.

📒 Files selected for processing (8)
  • frontend/app/components/modules/project/components/contributors/contributor-dependency.vue (1 hunks)
  • frontend/app/components/modules/project/components/contributors/contributors-leaderboard.vue (1 hunks)
  • frontend/app/components/modules/project/components/contributors/fragments/contributors-table.vue (1 hunks)
  • frontend/app/components/modules/project/components/contributors/fragments/metric-dropdown.vue (1 hunks)
  • frontend/app/components/modules/project/components/contributors/fragments/organizations-table.vue (1 hunks)
  • frontend/app/components/modules/project/components/contributors/geographical-distribution.vue (1 hunks)
  • frontend/app/components/modules/project/components/contributors/organization-dependency.vue (1 hunks)
  • frontend/app/components/modules/project/components/contributors/organizations-leaderboard.vue (1 hunks)
🔇 Additional comments (13)
frontend/app/components/modules/project/components/contributors/fragments/contributors-table.vue (2)

47-47: Updated metric comparison to use the new format

The condition has been updated to check for the new format "all:all" which aligns with the changes in the PR to handle platform and activity type separately.


53-53: Updated metric value processing to handle the new format

The code now correctly splits the metric string by ":" and uses the second part (activityType) to find the corresponding label in the flattened metrics options.

frontend/app/components/modules/project/components/contributors/fragments/organizations-table.vue (2)

47-47: Updated metric comparison to use the new format

The condition has been updated to check for the new format "all:all" which aligns with the changes in the PR to handle platform and activity type separately.


53-53: Updated metric value processing to handle the new format

The code now correctly splits the metric string by ":" and uses the second part (activityType) to find the corresponding label in the flattened metrics options.

frontend/app/components/modules/project/components/contributors/geographical-distribution.vue (4)

97-103: Enhanced metric options with platform and activity type

The metricOptions are now properly structured to include both platform and activity type in the format "platform:activityType". This refactoring provides better categorization and flexibility when selecting metrics from the dropdown.


106-106: Updated default metric value to match the new format

The default metric value has been changed from 'all' to 'all:all' to align with the new format that includes both platform and activity type.


108-109: Added computed properties to extract platform and activity type

These computed properties elegantly extract the platform and activityType from the metric value, allowing them to be used separately in API calls and other operations.


117-119: Updated API parameters to include platform and activity type

The useFetch call has been updated to use the new computed properties (platform and activityType) instead of a single metric parameter, providing more granular control over the data being requested.

frontend/app/components/modules/project/components/contributors/fragments/metric-dropdown.vue (1)

18-18: Added type import for improved type safety

The import of DropdownGroupOptions type enhances type safety when mapping through the metricsOptions.

frontend/app/components/modules/project/components/contributors/contributor-dependency.vue (1)

84-86: API parameters updated to match new structure

The parameters were correctly updated to use platform and activityType instead of the single metric parameter, aligning with the PR objectives.

frontend/app/components/modules/project/components/contributors/organization-dependency.vue (1)

84-86: API parameters updated to match new structure

API parameters have been consistently updated to use the new platform and activityType parameters.

frontend/app/components/modules/project/components/contributors/organizations-leaderboard.vue (1)

58-60: API parameters updated to match new structure

Parameters in the API call have been correctly updated to use the new platform and activityType fields.

frontend/app/components/modules/project/components/contributors/contributors-leaderboard.vue (1)

58-60: API parameters updated to match new structure

The API parameters have been properly updated to use platform and activityType instead of metric.

Comment on lines 20 to 26
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 17, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Enhanced metric options structure for dropdown

The metricOptions are now transformed with a more consistent structure that includes both platform and activity type in the format "platform:activityType". This change aligns with the PR objectives of improving platform handling within the dropdown select component.

However, there's an undefined type reference:

- items: option.items.map((item: DropdownItem) => ({
+ items: option.items.map((item: any) => ({

You need to either import the DropdownItem type or use an appropriate type that's already available in the current scope.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const metricOptions = metricsOptions.map((option: DropdownGroupOptions) => ({
label: option.label,
items: option.items.map((item: DropdownItem) => ({
label: item.label,
value: option.label ? `${option.label.toLowerCase()}:${item.value}` : `all:${item.value}`
}))
}));
const metricOptions = metricsOptions.map((option: DropdownGroupOptions) => ({
label: option.label,
items: option.items.map((item: any) => ({
label: item.label,
value: option.label ? `${option.label.toLowerCase()}:${item.value}` : `all:${item.value}`
}))
}));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This one seems important.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for DropdownItem type definition in the codebase
echo "Searching for DropdownItem type definition..."
rg "type\s+DropdownItem" --type ts

# Check the specific dropdown types file that's already being imported
echo "Checking the dropdown types file specifically..."
cat frontend/app/components/uikit/dropdown/types/dropdown.types.ts

# Check imports in the original file for any clues
echo "Checking imports in the metric-dropdown.vue file..."
grep "import" frontend/app/components/modules/project/components/contributors/fragments/metric-dropdown.vue

Length of output: 1704


@borfast Yes, this is indeed important! The code is using `DropdownItem` as a type, but that type isn't defined anywhere. Looking at the dropdown types file, I found that we should be using `DropdownOption` instead, which is the correct type for items in the `DropdownGroupOptions` interface.

Here's the fix:

import type { DropdownGroupOptions, DropdownOption } from '~/components/uikit/dropdown/types/dropdown.types';

const metricOptions = metricsOptions.map((option: DropdownGroupOptions) = > ({
  label: option.label,
  items: option.items.map((item: DropdownOption) => ({
    label: item.label,
    value: option.label ? `${option.label.toLowerCase()}:${item.value}` : `all:${item.value}`
  }))
}));

This will ensure type safety and prevent TypeScript compilation errors.

@borfast borfast closed this Mar 17, 2025
@borfast borfast force-pushed the improvement/pass-activity-platform branch from 1b99907 to 98c9440 Compare March 17, 2025 15:59
@borfast
Copy link
Copy Markdown
Contributor

borfast commented Mar 17, 2025

I mistakenly pushed this branch and somehow it seems to have closed this PR 🤔 Sorry Efren, my bad 🙏 I'll make sure the necessary changes are not forgotten.

@borfast
Copy link
Copy Markdown
Contributor

borfast commented Mar 17, 2025

I figured out what happened: due to the git add . in the pre-commit hook, a rebase added everything in my directory into the new commits created by the rebase, and thus the commits originally in this PR were merged in another PR. I'm opening another PR to fix the pre-commit hook.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants