-
Notifications
You must be signed in to change notification settings - Fork 86
fix: Fix time_in_draft iterator exhaustion and misnamed event #610
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
Conversation
Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
- Change event name from converted_to_draft to convert_to_draft to match actual GitHub timeline events - Remove problematic datetime parsing that was causing type errors - Update time calculation logic to properly handle draft state transitions - Make issue_metrics.py executable - Update corresponding test cases to use correct event names This fixes the draft PR metrics functionality to work with the actual GitHub API events. Signed-off-by: Zack Koppert <zkoppert@github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request fixes bugs in the draft time measurement functionality by correcting the GitHub API event name and improving compatibility with iterator-based event sources. The changes ensure the code works correctly with the real GitHub API.
- Standardized event name from "converted_to_draft" to "convert_to_draft" throughout code and tests
- Fixed iterator exhaustion issue by converting events to a list upfront
- Added test coverage for iterator-based events and improved test data consistency
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
time_in_draft.py | Updated event name, fixed iterator handling, and added result rounding |
test_time_in_draft.py | Updated all test cases with correct event name and added iterator test |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Zack Koppert <zkoppert@github.com>
This pull request updates the logic and tests for measuring the time a pull request spends in draft state. The main changes include standardizing the event name for draft conversions, improving compatibility with iterator-based event sources, updating test data types, and rounding the output for consistency.
Bug fixes and compatibility improvements:
Standardized the event name from
"converted_to_draft"
to"convert_to_draft"
throughout both the implementation and all test cases, ensuring consistency with the real GitHub API event names. [1] [2] [3] [4] [5] [6] [7] [8] [9]Modified the
measure_time_in_draft
function to convert the events iterator to a list at the start, ensuring compatibility with the real GitHub API, which returns an iterator that can only be consumed once.Test enhancements:
Added a new test (
test_time_in_draft_with_iterator_events
) to verify thatmeasure_time_in_draft
works correctly when the events method returns an iterator, simulating real-world API behavior.Updated test setup to use
datetime
objects forcreated_at
instead of ISO-formatted strings, aligning with the rest of the code and improving clarity. [1] [2]Accuracy improvements:
The result of
measure_time_in_draft
is now rounded to the nearest second for improved accuracy and consistency.Updated variable names in the implementation for clarity (e.g.,
converted_to_draft_events
→convert_to_draft_events
). [1] [2]These changes improve reliability, maintainability, and correctness of the draft time measurement logic and its associated tests. fixes #608