Skip to content

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

@adnanhashmi09

Description

@adnanhashmi09

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmediumModerate complexity issue

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions