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

Track accurate PR cycle time by identifying first ready-for-review time #634

Open
adnanhashmi09 opened this issue Mar 17, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@adnanhashmi09
Copy link
Contributor

Problem

Our current PR cycle time calculation has inaccuracies for PRs that start in draft state. We currently measure:

cycle_time = (time when PR state changed) - (time when PR was created)

This approach inflates the cycle time for PRs that begin as drafts, since the PR isn't actually ready for review when it's created. The clock should start when the PR is first ready for review.

Proposed Solution

We should modify our logic to calculate the first time a PR is open for review as follows:

  1. If PR was opened in a ready-for-review state:

    • first_open_time = pr.created_at
  2. If PR was opened in draft state:

    • first_open_time = timestamp when PR first moved to ready-for-review state
  3. If PR later toggles between draft and ready-for-review states:

    • Ignore subsequent transitions; only the first transition to ready-for-review matters

Implementation Notes

  • Need to track the PR state transition history
  • Only consider the first transition from draft to ready-for-review
  • Update the cycle time calculation to use first_open_time instead of pr.created_at

Benefits

  • More accurate cycle time metrics
  • Better representation of actual review time
  • Prevents inflation of metrics due to draft preparation time
@adnanhashmi09 adnanhashmi09 added the enhancement New feature or request label Mar 17, 2025
Ayyanaruto added a commit to Ayyanaruto/middleware that referenced this issue Mar 18, 2025
- Modified cycle time calculation to start timing when PR first becomes ready for review
- Added logic to detect the first transition from draft to ready state
- First ready event timestamp is used instead of PR creation time when applicable
- Provides more accurate metrics by excluding draft preparation time

Resolves issue middlewarehq#634
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant