Skip to content

Extract some tinybird response types to make them reusable on other widgets#168

Closed
borfast wants to merge 0 commit intomainfrom
improvement/extract-tinybird-response-types
Closed

Extract some tinybird response types to make them reusable on other widgets#168
borfast wants to merge 0 commit intomainfrom
improvement/extract-tinybird-response-types

Conversation

@borfast
Copy link
Copy Markdown
Contributor

@borfast borfast commented Apr 11, 2025

The Code Review Engagement widget needs data from both the contributors leaderboard, and the active contributors TinyBird endpoints, but the return types were in the respective data sources.

This PR moves those data sources to a separate module, so we can access them from the Code Review Engagement later.

Summary by CodeRabbit

  • Refactor
    • Streamlined the handling of contributor metrics to ensure improved consistency and data reliability for active contributor and leaderboard displays.
    • Enhanced the structure of contributor statistics to support more accurate and maintainable data processing.

@borfast borfast added the feature New feature or request label Apr 11, 2025
@borfast borfast requested a review from emlimlf April 11, 2025 01:03
@borfast borfast self-assigned this Apr 11, 2025
Copilot AI review requested due to automatic review settings April 11, 2025 01:03
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 2025

Walkthrough

This pull request updates the type definitions used in the Tinybird data sources. The changes remove redundant type aliases and replace them with direct references and new type imports from a newly introduced file. Both the active contributors and contributors leaderboard sources have been modified to use these new type definitions, streamlining data handling and ensuring consistent typing across the codebase.

Changes

File(s) Change Summary
frontend/.../active-contributors-data-source.ts - Added type imports for TinybirdActiveContributorsData and TinybirdActiveContributorsSummary from responses.types.
- Removed the alias ActiveContributorsResponseData and updated the data property in ActiveContributorsResponse to use ActiveContributorsDataPoint[].
- Explicitly typed processedData as ActiveContributorsDataPoint[] in the fetchActiveContributors function.
frontend/.../contributors-leaderboard-source.ts - Introduced a new import for TinybirdContributorsLeaderboardData from responses.types.
- Removed the alias ContributorsLeaderboardData and updated the data property in ContributorsLeaderboardResponse to use ContributorsLeaderboardDataPoint[].
- Updated the variable type for processedData in the fetchContributorsLeaderboard function accordingly.
frontend/.../responses.types.ts - Added a new file defining three exported types:
TinybirdActiveContributorsSummary: array of objects with a contributorCount number.
TinybirdActiveContributorsData: array of objects with startDate, endDate (strings), and contributorCount (number).
TinybirdContributorsLeaderboardData: array of objects with avatar, displayName (strings), and contribution details.

Possibly related PRs

  • [INS 326] Fix active contributors tests #137: The changes in the main PR are related to the modifications of type definitions and data handling for active contributors, which directly impacts the functionality tested in the retrieved PR's test cases for the fetchActiveContributors function.
  • Refactor data sources #76: The changes in the main PR are related to the modifications of type definitions and data handling for active contributors, while the retrieved PR focuses on refactoring data source creation for fetching active contributors, indicating a connection through the shared context of active contributors data management.
  • [INS 330] Create tests for contributors leaderboard #141: The changes in the main PR and the retrieved PR are related as both involve modifications to the ContributorsLeaderboardResponse type and its associated data handling, specifically in how types are defined and utilized in the fetchContributorsLeaderboard function.

Suggested reviewers

  • gaspergrom
  • emlimlf

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 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 cef583af68046c91cbd4e44e4e308cb61be6825e and fb954c556b6adad02b7c2f1f60a947e2c39addc2.

📒 Files selected for processing (1)
  • frontend/server/data/tinybird/responses.types.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/server/data/tinybird/responses.types.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 plan to trigger planning for file edits and PR creation.
  • @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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

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: 0

🧹 Nitpick comments (1)
frontend/server/data/tinybird/responses.types.ts (1)

13-19: Add missing semicolon for consistency

There's a missing semicolon at the end of line 19, while the rest of the file uses semicolons consistently.

  contributionCount: number,
  contributionPercentage: number
- }[];
+ }[];
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bbd7fc3 and cef583af68046c91cbd4e44e4e308cb61be6825e.

📒 Files selected for processing (3)
  • frontend/server/data/tinybird/active-contributors-data-source.ts (3 hunks)
  • frontend/server/data/tinybird/contributors-leaderboard-source.ts (3 hunks)
  • frontend/server/data/tinybird/responses.types.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
frontend/server/data/tinybird/active-contributors-data-source.ts (1)
Learnt from: borfast
PR: LF-Engineering/insights#76
File: frontend/server/data/tinybird/active-contributors-data-source.test.ts:10-10
Timestamp: 2025-04-10T15:19:07.017Z
Learning: The tests in the frontend/server/data/tinybird directory became broken due to changes introduced in another branch and will need to be revisited later as part of the data sources refactoring.
🔇 Additional comments (7)
frontend/server/data/tinybird/responses.types.ts (1)

1-2: Well-organized type definitions for Tinybird API responses

The creation of this file aligns well with the PR objective to extract response types and make them reusable across widgets.

frontend/server/data/tinybird/active-contributors-data-source.ts (3)

14-14: Good refactoring to import shared types

Importing the Tinybird response types from a dedicated file improves code organization and reusability across widgets.


30-30: Simplified type structure

Directly using ActiveContributorsDataPoint[] instead of a type alias improves code clarity and reduces unnecessary abstraction.


66-66: Consistent type usage

Properly updated the type annotation for processedData to match the type structure changes throughout the file.

frontend/server/data/tinybird/contributors-leaderboard-source.ts (3)

3-3: Good refactoring to import shared types

Importing the Tinybird response type from a dedicated file improves code organization and reusability.


18-18: Simplified type structure

Directly using ContributorsLeaderboardDataPoint[] instead of a type alias improves code clarity and reduces unnecessary abstraction.


32-32: Consistent type usage

Properly updated the type annotation for processedData to match the type structure changes throughout the file.

@borfast borfast closed this Apr 11, 2025
@borfast borfast force-pushed the improvement/extract-tinybird-response-types branch from fb954c5 to bbd7fc3 Compare April 11, 2025 01:10
@borfast
Copy link
Copy Markdown
Contributor Author

borfast commented Apr 11, 2025

This was closed inadvertently. There #169 to replace it.

@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

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants