From fe2bc4a4071c7981025d7cbe02b6c3fb420575b0 Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Wed, 23 Oct 2024 11:58:21 -0700 Subject: [PATCH] feat: add time_in_draft to json output Signed-off-by: Zack Koppert --- json_writer.py | 2 ++ test_json_writer.py | 5 +++++ time_in_draft.py | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/json_writer.py b/json_writer.py index 0b191dc..5655feb 100644 --- a/json_writer.py +++ b/json_writer.py @@ -55,6 +55,7 @@ def write_to_json( "time_to_first_response": "3 days, 0:00:00", "time_to_close": "6 days, 0:00:00", "time_to_answer": "None", + "time_in_draft": "1 day, 0:00:00", "label_metrics": { "bug": "1 day, 16:24:12" } @@ -152,6 +153,7 @@ def write_to_json( "time_to_first_response": str(issue.time_to_first_response), "time_to_close": str(issue.time_to_close), "time_to_answer": str(issue.time_to_answer), + "time_in_draft": str(issue.time_in_draft), "label_metrics": formatted_label_metrics, } ) diff --git a/test_json_writer.py b/test_json_writer.py index 5dae93c..36d1faa 100644 --- a/test_json_writer.py +++ b/test_json_writer.py @@ -24,6 +24,7 @@ def test_write_to_json(self): time_to_first_response=timedelta(days=3), time_to_close=timedelta(days=6), time_to_answer=None, + time_in_draft=timedelta(days=1), labels_metrics={ "bug": timedelta(days=1, hours=16, minutes=24, seconds=12) }, @@ -88,6 +89,7 @@ def test_write_to_json(self): "time_to_first_response": "3 days, 0:00:00", "time_to_close": "6 days, 0:00:00", "time_to_answer": "None", + "time_in_draft": "1 day, 0:00:00", "label_metrics": {"bug": "1 day, 16:24:12"}, }, { @@ -97,6 +99,7 @@ def test_write_to_json(self): "time_to_first_response": "2 days, 0:00:00", "time_to_close": "4 days, 0:00:00", "time_to_answer": "1 day, 0:00:00", + "time_in_draft": "None", "label_metrics": {}, }, ], @@ -180,6 +183,7 @@ def test_write_to_json_with_no_response(self): "time_to_first_response": "None", "time_to_close": "None", "time_to_answer": "None", + "time_in_draft": "None", "label_metrics": {}, }, { @@ -189,6 +193,7 @@ def test_write_to_json_with_no_response(self): "time_to_first_response": "None", "time_to_close": "None", "time_to_answer": "None", + "time_in_draft": "None", "label_metrics": {}, }, ], diff --git a/time_in_draft.py b/time_in_draft.py index 8a9f1c5..cef3a9b 100644 --- a/time_in_draft.py +++ b/time_in_draft.py @@ -17,7 +17,8 @@ def measure_time_in_draft( args: issue (github3.issues.Issue): A GitHub issue which has been pre-qualified as a pull request. - ready_for_review_at (datetime | None): The time the pull request was marked as ready for review. + ready_for_review_at (datetime | None): The time the pull request was marked as + ready for review. returns: Union[datetime, None]: The time the pull request was in draft state.