Skip to content

Commit 7317684

Browse files
committed
feat: add time to first review metric and update tests likewise
1 parent 627921c commit 7317684

7 files changed

Lines changed: 44 additions & 10 deletions

json_writer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,13 @@ def write_to_json(
172172
"average_time_in_draft": str(average_time_in_draft),
173173
"average_time_in_labels": average_time_in_labels,
174174
"median_time_to_first_response": str(med_time_to_first_response),
175+
"median_time_to_first_review": str(med_time_to_first_review),
175176
"median_time_to_close": str(med_time_to_close),
176177
"median_time_to_answer": str(med_time_to_answer),
177178
"median_time_in_draft": str(med_time_in_draft),
178179
"median_time_in_labels": med_time_in_labels,
179180
"90_percentile_time_to_first_response": str(p90_time_to_first_response),
181+
"90_percentile_time_to_first_review": str(p90_time_to_first_review),
180182
"90_percentile_time_to_close": str(p90_time_to_close),
181183
"90_percentile_time_to_answer": str(p90_time_to_answer),
182184
"90_percentile_time_in_draft": str(p90_time_in_draft),

test_assignee_integration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def test_assignee_in_markdown_output(self):
5454
try:
5555
write_to_markdown(
5656
issues_with_metrics=issues_with_metrics,
57+
average_time_to_first_review=None,
5758
average_time_to_first_response={
5859
"avg": timedelta(hours=3),
5960
"med": timedelta(hours=3),
@@ -132,6 +133,7 @@ def test_assignee_in_json_output(self):
132133
try:
133134
json_output = write_to_json(
134135
issues_with_metrics=issues_with_metrics,
136+
stats_time_to_first_review=None,
135137
stats_time_to_first_response={
136138
"avg": timedelta(hours=3),
137139
"med": timedelta(hours=3),

test_column_order_fix.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def test_status_and_created_at_columns_alignment(self):
5555
write_to_markdown(
5656
issues_with_metrics=issues_with_metrics,
5757
average_time_to_first_response=None,
58+
average_time_to_first_review=None,
5859
average_time_to_close=None,
5960
average_time_to_answer=None,
6061
average_time_in_draft=None,
@@ -80,7 +81,7 @@ def test_status_and_created_at_columns_alignment(self):
8081
# The table should have the columns in the correct order
8182
# and the data should be properly aligned
8283
expected_header = (
83-
"| Title | URL | Assignee | Author | Time to first response | "
84+
"| Title | URL | Assignee | Author | Time to first response | Time to first review | "
8485
"Time to close | Time to answer | Created At | Status |"
8586
)
8687
self.assertIn(expected_header, content)
@@ -92,7 +93,7 @@ def test_status_and_created_at_columns_alignment(self):
9293
"| Test Issue | https://github.com/user/repo/issues/1 | "
9394
"[assignee1](https://github.com/assignee1) | "
9495
"[testuser](https://github.com/testuser) | 1 day, 0:00:00 | "
95-
"2 days, 0:00:00 | 3 days, 0:00:00 | 2023-01-01T00:00:00Z | open |"
96+
"None | 2 days, 0:00:00 | 3 days, 0:00:00 | 2023-01-01T00:00:00Z | open |"
9697
)
9798
self.assertIn(expected_row, content)
9899

test_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def test_get_env_vars_with_github_app(self):
131131
hide_time_to_answer=False,
132132
hide_time_to_close=False,
133133
hide_time_to_first_response=False,
134+
hide_time_to_first_review=False,
134135
hide_created_at=True,
135136
hide_status=True,
136137
ignore_user=[],
@@ -187,6 +188,7 @@ def test_get_env_vars_with_token(self):
187188
hide_time_to_answer=False,
188189
hide_time_to_close=False,
189190
hide_time_to_first_response=False,
191+
hide_time_to_first_review=False,
190192
hide_created_at=True,
191193
hide_status=True,
192194
ignore_user=[],
@@ -292,6 +294,7 @@ def test_get_env_vars_optional_values(self):
292294
hide_time_to_answer=True,
293295
hide_time_to_close=True,
294296
hide_time_to_first_response=True,
297+
hide_time_to_first_review=False,
295298
hide_created_at=True,
296299
hide_status=True,
297300
ignore_user=[],
@@ -339,6 +342,7 @@ def test_get_env_vars_optionals_are_defaulted(self):
339342
hide_time_to_answer=False,
340343
hide_time_to_close=False,
341344
hide_time_to_first_response=False,
345+
hide_time_to_first_review=False,
342346
hide_created_at=True,
343347
hide_status=True,
344348
ignore_user=[],

test_json_writer.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,19 @@ def test_write_to_json(self):
7777

7878
expected_output = {
7979
"average_time_to_first_response": "2 days, 12:00:00",
80+
"average_time_to_first_review": "None",
8081
"average_time_to_close": "5 days, 0:00:00",
8182
"average_time_to_answer": "1 day, 0:00:00",
8283
"average_time_in_draft": "1 day, 0:00:00",
8384
"average_time_in_labels": {"bug": "1 day, 16:24:12"},
8485
"median_time_to_first_response": "2 days, 12:00:00",
86+
"median_time_to_first_review": "None",
8587
"median_time_to_close": "4 days, 0:00:00",
8688
"median_time_to_answer": "2 days, 0:00:00",
8789
"median_time_in_draft": "1 day, 0:00:00",
8890
"median_time_in_labels": {"bug": "1 day, 16:24:12"},
8991
"90_percentile_time_to_first_response": "1 day, 12:00:00",
92+
"90_percentile_time_to_first_review": "None",
9093
"90_percentile_time_to_close": "3 days, 0:00:00",
9194
"90_percentile_time_to_answer": "3 days, 0:00:00",
9295
"90_percentile_time_in_draft": "1 day, 0:00:00",
@@ -106,6 +109,7 @@ def test_write_to_json(self):
106109
"assignee": "charlie",
107110
"assignees": ["charlie"],
108111
"time_to_first_response": "3 days, 0:00:00",
112+
"time_to_first_review": "None",
109113
"time_to_close": "6 days, 0:00:00",
110114
"time_to_answer": "None",
111115
"time_in_draft": "1 day, 0:00:00",
@@ -120,6 +124,7 @@ def test_write_to_json(self):
120124
"assignee": None,
121125
"assignees": [],
122126
"time_to_first_response": "2 days, 0:00:00",
127+
"time_to_first_review": "None",
123128
"time_to_close": "4 days, 0:00:00",
124129
"time_to_answer": "1 day, 0:00:00",
125130
"time_in_draft": "None",
@@ -136,6 +141,7 @@ def test_write_to_json(self):
136141
write_to_json(
137142
issues_with_metrics=issues_with_metrics,
138143
stats_time_to_first_response=stats_time_to_first_response,
144+
stats_time_to_first_review=None,
139145
stats_time_to_close=stats_time_to_close,
140146
stats_time_to_answer=stats_time_to_answer,
141147
stats_time_in_draft=stats_time_in_draft,
@@ -194,16 +200,19 @@ def test_write_to_json_with_no_response(self):
194200

195201
expected_output = {
196202
"average_time_to_first_response": "None",
203+
"average_time_to_first_review": "None",
197204
"average_time_to_close": "None",
198205
"average_time_to_answer": "None",
199206
"average_time_in_draft": "None",
200207
"average_time_in_labels": {},
201208
"median_time_to_first_response": "None",
209+
"median_time_to_first_review": "None",
202210
"median_time_to_close": "None",
203211
"median_time_to_answer": "None",
204212
"median_time_in_draft": "None",
205213
"median_time_in_labels": {},
206214
"90_percentile_time_to_first_response": "None",
215+
"90_percentile_time_to_first_review": "None",
207216
"90_percentile_time_to_close": "None",
208217
"90_percentile_time_to_answer": "None",
209218
"90_percentile_time_in_draft": "None",
@@ -223,6 +232,7 @@ def test_write_to_json_with_no_response(self):
223232
"assignee": None,
224233
"assignees": [],
225234
"time_to_first_response": "None",
235+
"time_to_first_review": "None",
226236
"time_to_close": "None",
227237
"time_to_answer": "None",
228238
"time_in_draft": "None",
@@ -237,6 +247,7 @@ def test_write_to_json_with_no_response(self):
237247
"assignee": None,
238248
"assignees": [],
239249
"time_to_first_response": "None",
250+
"time_to_first_review": "None",
240251
"time_to_close": "None",
241252
"time_to_answer": "None",
242253
"time_in_draft": "None",
@@ -253,6 +264,7 @@ def test_write_to_json_with_no_response(self):
253264
write_to_json(
254265
issues_with_metrics=issues_with_metrics,
255266
stats_time_to_first_response=stats_time_to_first_response,
267+
stats_time_to_first_review=None,
256268
stats_time_to_close=stats_time_to_close,
257269
stats_time_to_answer=stats_time_to_answer,
258270
stats_time_in_draft=stats_time_in_draft,

test_markdown_writer.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def test_write_to_markdown(self):
103103
write_to_markdown(
104104
issues_with_metrics=issues_with_metrics,
105105
average_time_to_first_response=time_to_first_response,
106+
average_time_to_first_review=None,
106107
average_time_to_close=time_to_close,
107108
average_time_to_answer=time_to_answer,
108109
average_time_in_draft=time_in_draft,
@@ -126,6 +127,7 @@ def test_write_to_markdown(self):
126127
"| Metric | Average | Median | 90th percentile |\n"
127128
"| --- | --- | --- | ---: |\n"
128129
"| Time to first response | 2 days, 0:00:00 | 2 days, 0:00:00 | 2 days, 0:00:00 |\n"
130+
"| Time to first review | None | None | None |\n"
129131
"| Time to close | 3 days, 0:00:00 | 3 days, 0:00:00 | 3 days, 0:00:00 |\n"
130132
"| Time to answer | 4 days, 0:00:00 | 4 days, 0:00:00 | 4 days, 0:00:00 |\n"
131133
"| Time in draft | 1 day, 0:00:00 | 1 day, 0:00:00 | 1 day, 0:00:00 |\n"
@@ -137,13 +139,13 @@ def test_write_to_markdown(self):
137139
"| Number of items that remain open | 2 |\n"
138140
"| Number of items closed | 1 |\n"
139141
"| Total number of items created | 2 |\n\n"
140-
"| Title | URL | Assignee | Author | Time to first response | Time to close | "
142+
"| Title | URL | Assignee | Author | Time to first response | Time to first review | Time to close | "
141143
"Time to answer | Time in draft | Time spent in bug | Created At | Status |\n"
142-
"| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n"
144+
"| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n"
143145
"| Issue 1 | https://github.com/user/repo/issues/1 | [charlie](https://github.com/charlie) | "
144-
"[alice](https://github.com/alice) | 1 day, 0:00:00 | 2 days, 0:00:00 | 3 days, 0:00:00 | "
146+
"[alice](https://github.com/alice) | 1 day, 0:00:00 | None | 2 days, 0:00:00 | 3 days, 0:00:00 | "
145147
"1 day, 0:00:00 | 4 days, 0:00:00 | -5 days, 0:00:00 | None |\n"
146-
"| Issue 2 | https://github.com/user/repo/issues/2 | None | [bob](https://github.com/bob) | 3 days, 0:00:00 | "
148+
"| Issue 2 | https://github.com/user/repo/issues/2 | None | [bob](https://github.com/bob) | 3 days, 0:00:00 | None | "
147149
"4 days, 0:00:00 | 5 days, 0:00:00 | 1 day, 0:00:00 | 2 days, 0:00:00 | -5 days, 0:00:00 | None |\n\n"
148150
"_This report was generated with the [Issue Metrics Action](https://github.com/github-community-projects/issue-metrics)_\n"
149151
"Search query used to find these items: `is:issue is:open label:bug`\n"
@@ -223,6 +225,7 @@ def test_write_to_markdown_with_vertical_bar_in_title(self):
223225
write_to_markdown(
224226
issues_with_metrics=issues_with_metrics,
225227
average_time_to_first_response=average_time_to_first_response,
228+
average_time_to_first_review=None,
226229
average_time_to_close=average_time_to_close,
227230
average_time_to_answer=average_time_to_answer,
228231
average_time_in_draft=average_time_in_draft,
@@ -244,6 +247,7 @@ def test_write_to_markdown_with_vertical_bar_in_title(self):
244247
"| Metric | Average | Median | 90th percentile |\n"
245248
"| --- | --- | --- | ---: |\n"
246249
"| Time to first response | 2 days, 0:00:00 | 2 days, 0:00:00 | 2 days, 0:00:00 |\n"
250+
"| Time to first review | None | None | None |\n"
247251
"| Time to close | 3 days, 0:00:00 | 3 days, 0:00:00 | 3 days, 0:00:00 |\n"
248252
"| Time to answer | 4 days, 0:00:00 | 4 days, 0:00:00 | 4 days, 0:00:00 |\n"
249253
"| Time in draft | 1 day, 0:00:00 | 1 day, 0:00:00 | 1 day, 0:00:00 |\n"
@@ -255,14 +259,14 @@ def test_write_to_markdown_with_vertical_bar_in_title(self):
255259
"| Number of items that remain open | 2 |\n"
256260
"| Number of items closed | 1 |\n"
257261
"| Total number of items created | 2 |\n\n"
258-
"| Title | URL | Assignee | Author | Time to first response | Time to close | "
262+
"| Title | URL | Assignee | Author | Time to first response | Time to first review | Time to close | "
259263
"Time to answer | Time in draft | Time spent in bug | Created At | Status |\n"
260-
"| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n"
264+
"| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n"
261265
"| Issue 1 | https://github.com/user/repo/issues/1 | [charlie](https://github.com/charlie) | "
262-
"[alice](https://github.com/alice) | 1 day, 0:00:00 | 2 days, 0:00:00 | 3 days, 0:00:00 | "
266+
"[alice](https://github.com/alice) | 1 day, 0:00:00 | None | 2 days, 0:00:00 | 3 days, 0:00:00 | "
263267
"1 day, 0:00:00 | 1 day, 0:00:00 | -5 days, 0:00:00 | None |\n"
264268
"| feat| Issue 2 | https://github.com/user/repo/issues/2 | None | "
265-
"[bob](https://github.com/bob) | 3 days, 0:00:00 | "
269+
"[bob](https://github.com/bob) | 3 days, 0:00:00 | None | "
266270
"4 days, 0:00:00 | 5 days, 0:00:00 | None | 2 days, 0:00:00 | -5 days, 0:00:00 | None |\n\n"
267271
"_This report was generated with the [Issue Metrics Action](https://github.com/github-community-projects/issue-metrics)_\n"
268272
)
@@ -284,6 +288,7 @@ def test_write_to_markdown_no_issues(self):
284288
None,
285289
None,
286290
None,
291+
None,
287292
report_title="Issue Metrics",
288293
)
289294

@@ -310,6 +315,7 @@ def test_write_to_markdown_no_issues(self):
310315
"GH_TOKEN": "test_token",
311316
"HIDE_CREATED_AT": "False",
312317
"HIDE_TIME_TO_FIRST_RESPONSE": "True",
318+
"HIDE_TIME_TO_FIRST_REVIEW": "True",
313319
"HIDE_TIME_TO_CLOSE": "True",
314320
"HIDE_TIME_TO_ANSWER": "True",
315321
"HIDE_LABEL_METRICS": "True",
@@ -379,6 +385,7 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self):
379385
write_to_markdown(
380386
issues_with_metrics=issues_with_metrics,
381387
average_time_to_first_response=average_time_to_first_response,
388+
average_time_to_first_review=None,
382389
average_time_to_close=average_time_to_close,
383390
average_time_to_answer=average_time_to_answer,
384391
average_time_in_draft=average_time_in_draft,
@@ -428,6 +435,7 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self):
428435
"GH_TOKEN": "test_token",
429436
"HIDE_CREATED_AT": "False",
430437
"HIDE_TIME_TO_FIRST_RESPONSE": "True",
438+
"HIDE_TIME_TO_FIRST_REVIEW": "True",
431439
"HIDE_TIME_TO_CLOSE": "True",
432440
"HIDE_TIME_TO_ANSWER": "True",
433441
"HIDE_LABEL_METRICS": "True",
@@ -490,6 +498,7 @@ def test_writes_markdown_file_with_hidden_status_column(self):
490498
write_to_markdown(
491499
issues_with_metrics=issues_with_metrics,
492500
average_time_to_first_response=average_time_to_first_response,
501+
average_time_to_first_review=None,
493502
average_time_to_close=average_time_to_close,
494503
average_time_to_answer=average_time_to_answer,
495504
average_time_in_draft=average_time_in_draft,
@@ -538,6 +547,7 @@ def test_writes_markdown_file_with_hidden_status_column(self):
538547
"GH_TOKEN": "test_token",
539548
"HIDE_CREATED_AT": "False",
540549
"HIDE_TIME_TO_FIRST_RESPONSE": "True",
550+
"HIDE_TIME_TO_FIRST_REVIEW": "True",
541551
"HIDE_TIME_TO_CLOSE": "True",
542552
"HIDE_TIME_TO_ANSWER": "True",
543553
"HIDE_LABEL_METRICS": "True",
@@ -601,6 +611,7 @@ def test_writes_markdown_file_with_hidden_items_list(self):
601611
write_to_markdown(
602612
issues_with_metrics=issues_with_metrics,
603613
average_time_to_first_response=average_time_to_first_response,
614+
average_time_to_first_review=None,
604615
average_time_to_close=average_time_to_close,
605616
average_time_to_answer=average_time_to_answer,
606617
average_time_in_draft=average_time_in_draft,

test_sorting_grouping.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ def test_write_to_markdown_with_sorting(self):
297297
write_to_markdown(
298298
issues_with_metrics=issues_with_metrics,
299299
average_time_to_first_response=None,
300+
average_time_to_first_review=None,
300301
average_time_to_close=None,
301302
average_time_to_answer=None,
302303
average_time_in_draft=None,
@@ -357,6 +358,7 @@ def test_write_to_markdown_with_grouping(self):
357358
write_to_markdown(
358359
issues_with_metrics=issues_with_metrics,
359360
average_time_to_first_response=None,
361+
average_time_to_first_review=None,
360362
average_time_to_close=None,
361363
average_time_to_answer=None,
362364
average_time_in_draft=None,

0 commit comments

Comments
 (0)