Skip to content
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

feat: Adding 'Created_At' column, defaulting to false #460

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ This action can be configured to authenticate with GitHub App Installation or Pe
| `HIDE_TIME_TO_ANSWER` | False | False | If set to `true`, the time to answer a discussion will not be displayed in the generated Markdown file. |
| `HIDE_TIME_TO_CLOSE` | False | False | If set to `true`, the time to close will not be displayed in the generated Markdown file. |
| `HIDE_TIME_TO_FIRST_RESPONSE` | False | False | If set to `true`, the time to first response will not be displayed in the generated Markdown file. |
| `HIDE_CREATED_AT` | False | True | If set to `true`, the creation timestmap will not be displayed in the generated Markdown file. |
| `DRAFT_PR_TRACKING` | False | False | If set to `true`, draft PRs will be included in the metrics as a new column and in the summary stats. |
| `IGNORE_USERS` | False | False | A comma separated list of users to ignore when calculating metrics. (ie. `IGNORE_USERS: 'user1,user2'`). To ignore bots, append `[bot]` to the user (ie. `IGNORE_USERS: 'github-actions[bot]'`) Users in this list will also have their authored issues and pull requests removed from the Markdown table. |
| `ENABLE_MENTOR_COUNT` | False | False | If set to 'TRUE' count number of comments users left on discussions, issues and PRs and display number of active mentors |
Expand Down
2 changes: 2 additions & 0 deletions classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(
time_in_draft=None,
labels_metrics=None,
mentor_activity=None,
created_at=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update the docs above

):
self.title = title
self.html_url = html_url
Expand All @@ -47,3 +48,4 @@ def __init__(
self.time_in_draft = time_in_draft
self.label_metrics = labels_metrics
self.mentor_activity = mentor_activity
self.created_at = created_at
5 changes: 5 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(
hide_time_to_answer: bool,
hide_time_to_close: bool,
hide_time_to_first_response: bool,
hide_created_at: bool,
ignore_user: List[str],
labels_to_measure: List[str],
enable_mentor_count: bool,
Expand Down Expand Up @@ -97,6 +98,7 @@ def __init__(
self.hide_time_to_answer = hide_time_to_answer
self.hide_time_to_close = hide_time_to_close
self.hide_time_to_first_response = hide_time_to_first_response
self.hide_created_at = hide_created_at
self.enable_mentor_count = enable_mentor_count
self.min_mentor_comments = min_mentor_comments
self.max_comments_eval = max_comments_eval
Expand All @@ -123,6 +125,7 @@ def __repr__(self):
f"{self.hide_time_to_answer},"
f"{self.hide_time_to_close},"
f"{self.hide_time_to_first_response},"
f"{self.hide_created_at},"
f"{self.ignore_users},"
f"{self.labels_to_measure},"
f"{self.enable_mentor_count},"
Expand Down Expand Up @@ -229,6 +232,7 @@ def get_env_vars(test: bool = False) -> EnvVars:
hide_time_to_answer = get_bool_env_var("HIDE_TIME_TO_ANSWER", False)
hide_time_to_close = get_bool_env_var("HIDE_TIME_TO_CLOSE", False)
hide_time_to_first_response = get_bool_env_var("HIDE_TIME_TO_FIRST_RESPONSE", False)
hide_created_at = get_bool_env_var("HIDE_CREATED_AT", True)
enable_mentor_count = get_bool_env_var("ENABLE_MENTOR_COUNT", False)
min_mentor_comments = os.getenv("MIN_MENTOR_COMMENTS", "10")
max_comments_eval = os.getenv("MAX_COMMENTS_EVAL", "20")
Expand All @@ -248,6 +252,7 @@ def get_env_vars(test: bool = False) -> EnvVars:
hide_time_to_answer,
hide_time_to_close,
hide_time_to_first_response,
hide_created_at,
ignore_users_list,
labels_to_measure_list,
enable_mentor_count,
Expand Down
5 changes: 5 additions & 0 deletions issue_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def get_per_issue_metrics(
)
else:
num_issues_open += 1
if env_vars.hide_created_at is False:
issue_with_metrics.created_at = issue.created_at
else:
if ignore_users and issue.user["login"] in ignore_users: # type: ignore
continue
Expand Down Expand Up @@ -159,6 +161,9 @@ def get_per_issue_metrics(
)
elif issue.state == "open": # type: ignore
num_issues_open += 1
if env_vars.hide_created_at is False:
issue_with_metrics.created_at = issue.created_at

Copy link
Member

@jmeridth jmeridth Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if not env_vars.hide_created_at:
issue_with_metrics.created_at = issue["createdAt"]

we don't need the above in both the if and else. it can go once here. wdyt?

The issue["createdAt"] also fixes your mypy linting issue.

issues_with_metrics.append(issue_with_metrics)

return issues_with_metrics, num_issues_open, num_issues_closed
Expand Down
6 changes: 6 additions & 0 deletions markdown_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def get_non_hidden_columns(labels) -> List[str]:
if not hide_label_metrics and labels:
for label in labels:
columns.append(f"Time spent in {label}")
hide_created_at = env_vars.hide_created_at
if not hide_created_at:
columns.append(f'Created At')

return columns

Expand Down Expand Up @@ -212,6 +215,8 @@ def write_to_markdown(
for label in labels:
if f"Time spent in {label}" in columns:
file.write(f" {issue.label_metrics[label]} |")
if "Created At" in columns:
file.write(f" {issue.created_at} |")
file.write("\n")
file.write(
"\n_This report was generated with the \
Expand Down Expand Up @@ -303,6 +308,7 @@ def write_overall_metrics_tables(
f"| {stats_time_in_labels['med'][label]} "
f"| {stats_time_in_labels['90p'][label]} |\n"
)

file.write("\n")
# Write count stats to a separate table
file.write("| Metric | Count |\n")
Expand Down
4 changes: 4 additions & 0 deletions test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def test_get_env_vars_with_github_app(self):
hide_time_to_answer=False,
hide_time_to_close=False,
hide_time_to_first_response=False,
hide_created_at=True,
ignore_user=[],
labels_to_measure=[],
enable_mentor_count=False,
Expand Down Expand Up @@ -181,6 +182,7 @@ def test_get_env_vars_with_token(self):
hide_time_to_answer=False,
hide_time_to_close=False,
hide_time_to_first_response=False,
hide_created_at=True,
ignore_user=[],
labels_to_measure=[],
enable_mentor_count=False,
Expand Down Expand Up @@ -269,6 +271,7 @@ def test_get_env_vars_optional_values(self):
hide_time_to_answer=True,
hide_time_to_close=True,
hide_time_to_first_response=True,
hide_created_at=True,
ignore_user=[],
labels_to_measure=["waiting-for-review", "waiting-for-manager"],
enable_mentor_count=False,
Expand Down Expand Up @@ -311,6 +314,7 @@ def test_get_env_vars_optionals_are_defaulted(self):
hide_time_to_answer=False,
hide_time_to_close=False,
hide_time_to_first_response=False,
hide_created_at=True,
ignore_user=[],
labels_to_measure=[],
enable_mentor_count=False,
Expand Down
Loading