Skip to content

Commit

Permalink
feat: Add time in draft to IssueWithMetrics class attributes and upda…
Browse files Browse the repository at this point in the history
…te failing tests that were using positional args

Signed-off-by: Zack Koppert <[email protected]>
  • Loading branch information
zkoppert committed Oct 23, 2024
1 parent f968e7b commit 2f68484
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 29 deletions.
3 changes: 3 additions & 0 deletions classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class IssueWithMetrics:
time_to_close (timedelta, optional): The time it took to close the issue.
time_to_answer (timedelta, optional): The time it took to answer the
discussions in the issue.
time_in_draft (timedelta, optional): The time the PR was in draft state.
label_metrics (dict, optional): A dictionary containing the label metrics
mentor_activity (dict, optional): A dictionary containing active mentors
Expand All @@ -33,6 +34,7 @@ def __init__(
time_to_first_response=None,
time_to_close=None,
time_to_answer=None,
time_in_draft=None,
labels_metrics=None,
mentor_activity=None,
):
Expand All @@ -42,5 +44,6 @@ def __init__(
self.time_to_first_response = time_to_first_response
self.time_to_close = time_to_close
self.time_to_answer = time_to_answer
self.time_in_draft = time_in_draft
self.label_metrics = labels_metrics
self.mentor_activity = mentor_activity
8 changes: 7 additions & 1 deletion test_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ def setUp(self):
self.issues_with_metrics = MagicMock()
self.issues_with_metrics = [
IssueWithMetrics(
"issue1", "url1", "alice", None, None, None, {"bug": timedelta(days=2)}
title="issue1",
html_url="url1",
author="alice",
time_to_first_response=None,
time_to_close=None,
time_to_answer=None,
labels_metrics={"bug": timedelta(days=2)},
),
]

Expand Down
56 changes: 28 additions & 28 deletions test_markdown_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ def test_write_to_markdown(self):
# Create mock data
issues_with_metrics = [
IssueWithMetrics(
"Issue 1",
"https://github.com/user/repo/issues/1",
"alice",
timedelta(days=1),
timedelta(days=2),
timedelta(days=3),
{"bug": timedelta(days=1)},
title="Issue 1",
html_url="https://github.com/user/repo/issues/1",
author="alice",
time_to_first_response=timedelta(days=1),
time_to_close=timedelta(days=2),
time_to_answer=timedelta(days=3),
labels_metrics={"bug": timedelta(days=1)},
),
IssueWithMetrics(
"Issue 2\r",
"https://github.com/user/repo/issues/2",
"bob",
timedelta(days=3),
timedelta(days=4),
timedelta(days=5),
{"bug": timedelta(days=2)},
title="Issue 2\r",
html_url="https://github.com/user/repo/issues/2",
author="bob",
time_to_first_response=timedelta(days=3),
time_to_close=timedelta(days=4),
time_to_answer=timedelta(days=5),
labels_metrics={"bug": timedelta(days=2)},
),
]
time_to_first_response = {
Expand Down Expand Up @@ -139,22 +139,22 @@ def test_write_to_markdown_with_vertical_bar_in_title(self):
# Create mock data
issues_with_metrics = [
IssueWithMetrics(
"Issue 1",
"https://github.com/user/repo/issues/1",
"alice",
timedelta(days=1),
timedelta(days=2),
timedelta(days=3),
{"bug": timedelta(days=1)},
title="Issue 1",
html_url="https://github.com/user/repo/issues/1",
author="alice",
time_to_first_response=timedelta(days=1),
time_to_close=timedelta(days=2),
time_to_answer=timedelta(days=3),
labels_metrics={"bug": timedelta(days=1)},
),
IssueWithMetrics(
"feat| Issue 2", # title contains a vertical bar
"https://github.com/user/repo/issues/2",
"bob",
timedelta(days=3),
timedelta(days=4),
timedelta(days=5),
{"bug": timedelta(days=2)},
title="feat| Issue 2", # title contains a vertical bar
html_url="https://github.com/user/repo/issues/2",
author="bob",
time_to_first_response=timedelta(days=3),
time_to_close=timedelta(days=4),
time_to_answer=timedelta(days=5),
labels_metrics={"bug": timedelta(days=2)},
),
]
average_time_to_first_response = {
Expand Down

0 comments on commit 2f68484

Please sign in to comment.