Skip to content

[INS-241] Fix filtering by repository on the widget data sources#120

Merged
borfast merged 1 commit intomainfrom
bugfix/ins-241-fix-repository-filtering
Mar 18, 2025
Merged

[INS-241] Fix filtering by repository on the widget data sources#120
borfast merged 1 commit intomainfrom
bugfix/ins-241-fix-repository-filtering

Conversation

@borfast
Copy link
Copy Markdown
Contributor

@borfast borfast commented Mar 18, 2025

Linear ticket

Due to the discrepancy between the variable names in the frontend and TinyBird, the repository / repo parameter was not being correctly used to filter data from TinyBird. This PR fixes that.

Summary by CodeRabbit

  • Refactor

    • Standardized filtering parameters across multiple endpoints for consistent data handling.
  • Style

    • Streamlined the parameter assignment process to enhance code clarity and maintainability.

These internal improvements ensure that data queries and filtering work uniformly across various project statistics features, leading to enhanced system reliability and performance without changing the overall user experience.

@borfast borfast added the bug Something isn't working label Mar 18, 2025
@borfast borfast requested review from emlimlf and gaspergrom March 18, 2025 00:53
@borfast borfast self-assigned this Mar 18, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 18, 2025

Walkthrough

This pull request consolidates changes across various API endpoints and data source modules. Most modifications involve renaming the repository property to repo in filter objects, ensuring consistency across endpoints handling contributor and organization data, popularity metrics, and Tinybird queries. Additionally, one endpoint has its granularity property assignment condensed into a single line, and type definitions have been updated accordingly.

Changes

File(s) Change Summary
frontend/server/api/project/[slug]/contributors/active-contributors.get.ts Consolidated the multi-line assignment of the granularity property into a single-line statement within the filter object.
`frontend/.../contributors/(active-organizations contributor-leaderboard
`frontend/server/api/project/[slug]/popularity/(forks get stars).get.ts`
`frontend/server/data/tinybird/(active-organizations-data-source forks-data-source
frontend/server/data/types.ts Updated several type definitions by renaming repository to repo across filter interfaces and reorganized the import for ActivityTypes.

Possibly related PRs

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 b76478716d7c9e3ea821cd86d9d0fa5927536b74 and a438407.

📒 Files selected for processing (13)
  • frontend/server/api/project/[slug]/contributors/active-contributors.get.ts (1 hunks)
  • frontend/server/api/project/[slug]/contributors/active-organizations.get.ts (1 hunks)
  • frontend/server/api/project/[slug]/contributors/contributor-leaderboard.get.ts (1 hunks)
  • frontend/server/api/project/[slug]/contributors/geographical-distribution.get.ts (1 hunks)
  • frontend/server/api/project/[slug]/contributors/organization-dependency.get.ts (2 hunks)
  • frontend/server/api/project/[slug]/contributors/organization-leaderboard.get.ts (1 hunks)
  • frontend/server/api/project/[slug]/contributors/retention.get.ts (1 hunks)
  • frontend/server/api/project/[slug]/popularity/forks.get.ts (1 hunks)
  • frontend/server/api/project/[slug]/popularity/stars.get.ts (1 hunks)
  • frontend/server/data/tinybird/active-organizations-data-source.ts (1 hunks)
  • frontend/server/data/tinybird/forks-data-source.ts (1 hunks)
  • frontend/server/data/tinybird/stars-data-source.ts (1 hunks)
  • frontend/server/data/types.ts (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (13)
  • frontend/server/api/project/[slug]/contributors/retention.get.ts
  • frontend/server/data/tinybird/active-organizations-data-source.ts
  • frontend/server/data/tinybird/forks-data-source.ts
  • frontend/server/api/project/[slug]/contributors/active-organizations.get.ts
  • frontend/server/api/project/[slug]/popularity/stars.get.ts
  • frontend/server/api/project/[slug]/popularity/forks.get.ts
  • frontend/server/api/project/[slug]/contributors/geographical-distribution.get.ts
  • frontend/server/data/tinybird/stars-data-source.ts
  • frontend/server/api/project/[slug]/contributors/active-contributors.get.ts
  • frontend/server/api/project/[slug]/contributors/organization-leaderboard.get.ts
  • frontend/server/api/project/[slug]/contributors/contributor-leaderboard.get.ts
  • frontend/server/data/types.ts
  • frontend/server/api/project/[slug]/contributors/organization-dependency.get.ts

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

@borfast borfast force-pushed the bugfix/ins-241-fix-repository-filtering branch from 58a9232 to b764787 Compare March 18, 2025 00:55
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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 2

🧹 Nitpick comments (1)
frontend/server/api/project/[slug]/popularity/forks.get.ts (1)

25-30: Update code comments to reflect property name change

The code comments still reference the old property name. Consider updating the comments to reflect the new naming convention.

 /**
  * Query params:
  * - type: 'cumulative' | 'new'
  * - project: string
- * - repository: string
+ * - repository: string (mapped to 'repo' internally)
  * - time-period: string // This is isn't defined yet, but we'll add '90d', '1y', '5y' for now
  */
🛑 Comments failed to post (2)
frontend/server/api/project/[slug]/contributors/organization-dependency.get.ts (1)

2-2: ⚠️ Potential issue

Fix import statement to use type import

The import of OrganizationDependencyFilter should use the import type syntax since it's only used as a type annotation.

-import {FilterActivityMetric, FilterGranularity, OrganizationDependencyFilter} from "~~/server/data/types";
+import {FilterActivityMetric, FilterGranularity} from "~~/server/data/types";
+import type {OrganizationDependencyFilter} from "~~/server/data/types";
📝 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.

import {FilterActivityMetric, FilterGranularity} from "~~/server/data/types";
import type {OrganizationDependencyFilter} from "~~/server/data/types";
🧰 Tools
🪛 GitHub Actions: Lint & Typescript Check

[error] 2-2: Imports "OrganizationDependencyFilter" are only used as type @typescript-eslint/consistent-type-imports

frontend/server/api/project/[slug]/contributors/contributor-dependency.get.ts (1)

3-3: ⚠️ Potential issue

Fix the type import syntax to resolve the linting error.

The linter is flagging an error because ContributorDependencyFilter is only used as a type. To resolve this, you should use import type syntax.

-import {ContributorDependencyFilter, FilterActivityMetric, FilterGranularity} from "~~/server/data/types";
+import {FilterActivityMetric, FilterGranularity} from "~~/server/data/types";
+import type {ContributorDependencyFilter} from "~~/server/data/types";
📝 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.

import {FilterActivityMetric, FilterGranularity} from "~~/server/data/types";
import type {ContributorDependencyFilter} from "~~/server/data/types";
🧰 Tools
🪛 GitHub Actions: Lint & Typescript Check

[error] 3-3: Imports "ContributorDependencyFilter" are only used as type @typescript-eslint/consistent-type-imports

@borfast borfast changed the title Fix filtering by repository on the widget data sources [INS-241] Fix filtering by repository on the widget data sources Mar 18, 2025
Signed-off-by: Raúl Santos <4837+borfast@users.noreply.github.com>
@borfast borfast force-pushed the bugfix/ins-241-fix-repository-filtering branch from 0ae4b3b to a438407 Compare March 18, 2025 11:11
@borfast borfast merged commit 514685c into main Mar 18, 2025
3 checks passed
@borfast borfast deleted the bugfix/ins-241-fix-repository-filtering branch March 18, 2025 11:13
@borfast borfast assigned borfast and unassigned borfast May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants