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

Feature: Time from rerequest to response(PR author perspective) #59

Merged
merged 10 commits into from
Jan 7, 2025

Conversation

AlexSim93
Copy link
Owner

@AlexSim93 AlexSim93 commented Jan 7, 2025

Pull Request

Description

  • Added Time to Review After Re-request metric. It will help to understand how much time PR's authors has been waiting for review.
  • Removed validations from the action
  • Updated examples and configs
  • Fixed unnecessary comment creation

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Other (please specify)

How Has This Been Tested?

Added unit-tests. Checked it on different repositories.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • I have added tests to cover my changes.
  • My changes generate no new warnings.
  • I have updated the documentation accordingly.

Summary by CodeRabbit

  • Analytics

    • Enhanced tracking by adding GitHub ownership and repository metrics
  • Performance

    • Added new metric for time waiting for repeated reviews
    • Improved response time calculations
  • Visualization

    • Updated timeline chart and table to include new review waiting time metric
  • Validation

    • Removed previous validation utilities and checks
  • Chores

    • Cleaned up and simplified validation and input processing logic

Copy link

coderabbitai bot commented Jan 7, 2025

Walkthrough

This pull request introduces enhancements to tracking and analytics functionality, focusing on adding new metrics related to GitHub repository and review processes. The changes involve removing validation utilities, adding new properties for tracking GitHub ownership and repository information, and introducing metrics for time spent waiting for repeated reviews. The modifications span multiple files across analytics, converters, view, and utility modules, with a significant refactoring of validation-related code.

Changes

File Change Summary
src/analytics/sendActionRun.ts Added two new tracking properties: GITHUB_OWNER_FOR_ISSUE and GITHUB_REPO_FOR_ISSUE lengths
src/common/utils/validate.ts
src/common/utils/validators/*
Removed validation utility functions and related files
src/converters/types.ts Added optional timeWaitingForRepeatedReview property to TimelinePoints and Collection types
src/converters/utils/preparePullRequestStats.ts Added calculations for timeWaitingForRepeatedReview metrics
src/converters/utils/prepareResponseTime.ts Enhanced response time processing with new time waiting calculation
src/index.ts Removed validation function call and associated error handling
src/view/utils/constants.ts Added timeAwaitingRepeatedReviewHeader constant
src/view/utils/createTimelineMonthXYChart.ts Added new data series for "Time To Review After Rerequest"
src/view/utils/createTimelineTable.ts Incorporated new header and data point for repeated review waiting time

Sequence Diagram

sequenceDiagram
    participant Analytics as SendActionRun
    participant Converters as PullRequestStats
    participant View as TimelineVisualization
    
    Analytics->>Converters: Track GitHub ownership metrics
    Converters->>Converters: Calculate repeated review times
    Converters->>View: Prepare timeline data
    View->>View: Render chart and table with new metrics
Loading

Possibly related PRs

  • None with a strong code-level connection based on the provided information.

Poem

🐰 Validation's gone, metrics arise,
Tracking GitHub with rabbit-like eyes!
Repeated reviews, time's gentle dance,
Code evolves with each clever glance.
Hop into insights, metrics so bright! 🚀


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>, 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. (Beta)
  • @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 or @coderabbitai review 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

@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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cd1c246 and 4b85b2b.

⛔ Files ignored due to path filters (10)
  • README.md is excluded by none and included by none
  • build/index.js is excluded by !build/** and included by none
  • configs/lastMonthsReport.yml is excluded by none and included by none
  • configs/manualTriggerForAllReposOfOrg.yml is excluded by none and included by none
  • configs/updateReportOnPRClose.yml is excluded by none and included by none
  • configs/yearReportWithoutDevelopers.yml is excluded by none and included by none
  • examples/collectionExample.json is excluded by none and included by none
  • examples/nPRsReport.md is excluded by none and included by none
  • examples/periodReport.md is excluded by none and included by none
  • package.json is excluded by none and included by none
📒 Files selected for processing (18)
  • src/analytics/sendActionRun.ts (1 hunks)
  • src/common/utils/index.ts (0 hunks)
  • src/common/utils/validate.ts (0 hunks)
  • src/common/utils/validators/index.ts (0 hunks)
  • src/common/utils/validators/validateDate.ts (0 hunks)
  • src/common/utils/validators/validateMultipleValues.ts (0 hunks)
  • src/common/utils/validators/validateNumber.ts (0 hunks)
  • src/common/utils/validators/validateRequired.ts (0 hunks)
  • src/common/utils/validators/validateSingleValue.ts (0 hunks)
  • src/converters/types.ts (2 hunks)
  • src/converters/utils/calculations/getApproveTime.spec.ts (2 hunks)
  • src/converters/utils/preparePullRequestStats.ts (3 hunks)
  • src/converters/utils/prepareResponseTime.ts (2 hunks)
  • src/createOutput.ts (1 hunks)
  • src/index.ts (0 hunks)
  • src/view/utils/constants.ts (1 hunks)
  • src/view/utils/createTimelineMonthXYChart.ts (3 hunks)
  • src/view/utils/createTimelineTable.ts (3 hunks)
💤 Files with no reviewable changes (9)
  • src/common/utils/index.ts
  • src/index.ts
  • src/common/utils/validators/validateDate.ts
  • src/common/utils/validate.ts
  • src/common/utils/validators/validateNumber.ts
  • src/common/utils/validators/validateRequired.ts
  • src/common/utils/validators/validateSingleValue.ts
  • src/common/utils/validators/index.ts
  • src/common/utils/validators/validateMultipleValues.ts
🧰 Additional context used
🪛 Biome (1.9.4)
src/converters/utils/prepareResponseTime.ts

[error] 29-29: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)

🔇 Additional comments (11)
src/view/utils/constants.ts (1)

5-6: LGTM! The new constant follows the established pattern.

The new header constant is well-named and maintains consistency with existing constants.

src/view/utils/createTimelineTable.ts (3)

3-3: LGTM! Import added correctly.

The new header constant is properly imported alongside other constants.


32-34: LGTM! Time metric formatting follows the established pattern.

The new time metric is properly integrated with:

  • Consistent use of optional chaining
  • Same formatting function as other time metrics

53-53: LGTM! Header properly added to table configuration.

The new header is correctly integrated into the table headers array.

src/analytics/sendActionRun.ts (1)

12-13: LGTM! Analytics properties added with proper null safety.

The new tracking properties are well-integrated with:

  • Proper use of optional chaining for null safety
  • Consistent pattern of tracking value lengths
src/converters/types.ts (1)

16-16: LGTM! Types properly defined for the new metric.

The new property is well-integrated in both types:

  • Properly marked as optional with ?
  • Consistent naming across types
  • Correct type definitions (number for TimelinePoints, number[] for Collection)

Also applies to: 74-74

src/converters/utils/preparePullRequestStats.ts (1)

76-78: LGTM! Consistent implementation of the new metric.

The new metric timeWaitingForRepeatedReview has been correctly added to all statistical calculations (median, percentile, and average), following the established patterns in the codebase.

Also applies to: 95-97, 114-116

src/converters/utils/calculations/getApproveTime.spec.ts (1)

115-131: LGTM! Well-structured test case for dismissed reviews.

The new test case thoroughly covers the scenario where a second reviewer dismisses their changes_requested review, ensuring the function returns the correct timestamp.

Also applies to: 170-174

src/converters/utils/prepareResponseTime.ts (1)

21-56: LGTM! Robust implementation with proper error handling.

The implementation properly handles:

  • Fallback for missing user login
  • Working hours and holidays in time calculations
  • Team-based aggregation
🧰 Tools
🪛 Biome (1.9.4)

[error] 29-29: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)

src/view/utils/createTimelineMonthXYChart.ts (1)

36-36: LGTM! Consistent visualization of the new metric.

The new metric has been properly integrated into the chart with:

  • Appropriate color scheme (turquoise)
  • Consistent time unit conversion (to hours)
  • Type-safe implementation

Also applies to: 49-49, 141-155

src/createOutput.ts (1)

111-111: 🧹 Nitpick (assertive)

Reconsider the arbitrary threshold for comment creation.

The condition dates.length < 3 seems arbitrary and could lead to loss of information. If there are 1-2 dates with valid markdown content, their comments won't be created even though they might contain valuable insights.

Consider the following:

  1. Document why exactly 3 dates were chosen as the threshold
  2. Make this threshold configurable through a constant or environment variable
  3. Alternatively, create comments for all dates that have valid markdown content, regardless of the total number of dates

Would you like me to propose a more flexible implementation that preserves all valid date-specific analytics while still achieving the goal of reducing unnecessary comments?

src/converters/utils/prepareResponseTime.ts Show resolved Hide resolved
@AlexSim93 AlexSim93 changed the base branch from master to v4 January 7, 2025 16:39
@AlexSim93 AlexSim93 merged commit 4d9ccad into v4 Jan 7, 2025
2 checks passed
@AlexSim93 AlexSim93 deleted the feature/default-behaviour branch January 7, 2025 16:39
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.

1 participant