Skip to content

Commit fb669c9

Browse files
committed
feat: add status column feature with configs to hide it
Signed-off-by: Zack Koppert <[email protected]>
1 parent 7112261 commit fb669c9

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ This action can be configured to authenticate with GitHub App Installation or Pe
129129
##### GitHub App Installation
130130

131131
| field | required | default | description |
132-
| ---------------------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
132+
| ---------------------------- | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
133133
| `GH_APP_ID` | True | `""` | GitHub Application ID. See [documentation](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/about-authentication-with-a-github-app) for more details. |
134134
| `GH_APP_INSTALLATION_ID` | True | `""` | GitHub Application Installation ID. See [documentation](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/about-authentication-with-a-github-app) for more details. |
135135
| `GH_APP_PRIVATE_KEY` | True | `""` | GitHub Application Private Key. See [documentation](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/about-authentication-with-a-github-app) for more details. |
@@ -154,7 +154,8 @@ This action can be configured to authenticate with GitHub App Installation or Pe
154154
| `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. |
155155
| `HIDE_TIME_TO_CLOSE` | False | False | If set to `true`, the time to close will not be displayed in the generated Markdown file. |
156156
| `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. |
157-
| `HIDE_CREATED_AT` | False | True | If set to `true`, the creation timestmap will not be displayed in the generated Markdown file. |
157+
| `HIDE_STATUS` | False | True | If set to `true`, the status column will not be shown |
158+
| `HIDE_CREATED_AT` | False | True | If set to `true`, the creation timestamp will not be displayed in the generated Markdown file. |
158159
| `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. |
159160
| `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. |
160161
| `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 |

config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class EnvVars:
3939
hide_time_to_close (bool): If true, the time to close metric is hidden in the output
4040
hide_time_to_first_response (bool): If true, the time to first response metric is hidden
4141
in the output
42+
hide_created_at (bool): If true, the created at timestamp is hidden in the output
43+
hide_status (bool): If true, the status column is hidden in the output
4244
ignore_users (List[str]): List of usernames to ignore when calculating metrics
4345
labels_to_measure (List[str]): List of labels to measure how much time the label is applied
4446
enable_mentor_count (bool): If set to TRUE, compute number of mentors
@@ -73,6 +75,7 @@ def __init__(
7375
hide_time_to_close: bool,
7476
hide_time_to_first_response: bool,
7577
hide_created_at: bool,
78+
hide_status: bool, # New attribute
7679
ignore_user: List[str],
7780
labels_to_measure: List[str],
7881
enable_mentor_count: bool,
@@ -102,6 +105,7 @@ def __init__(
102105
self.hide_time_to_close = hide_time_to_close
103106
self.hide_time_to_first_response = hide_time_to_first_response
104107
self.hide_created_at = hide_created_at
108+
self.hide_status = hide_status # Initialize the new attribute
105109
self.enable_mentor_count = enable_mentor_count
106110
self.min_mentor_comments = min_mentor_comments
107111
self.max_comments_eval = max_comments_eval
@@ -238,6 +242,7 @@ def get_env_vars(test: bool = False) -> EnvVars:
238242
hide_time_to_close = get_bool_env_var("HIDE_TIME_TO_CLOSE", False)
239243
hide_time_to_first_response = get_bool_env_var("HIDE_TIME_TO_FIRST_RESPONSE", False)
240244
hide_created_at = get_bool_env_var("HIDE_CREATED_AT", True)
245+
hide_status = get_bool_env_var("HIDE_STATUS", True) # New attribute
241246
enable_mentor_count = get_bool_env_var("ENABLE_MENTOR_COUNT", False)
242247
min_mentor_comments = os.getenv("MIN_MENTOR_COMMENTS", "10")
243248
max_comments_eval = os.getenv("MAX_COMMENTS_EVAL", "20")
@@ -259,6 +264,7 @@ def get_env_vars(test: bool = False) -> EnvVars:
259264
hide_time_to_close,
260265
hide_time_to_first_response,
261266
hide_created_at,
267+
hide_status,
262268
ignore_users_list,
263269
labels_to_measure_list,
264270
enable_mentor_count,

markdown_writer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ def get_non_hidden_columns(labels) -> List[str]:
7575
if not hide_time_to_answer:
7676
columns.append("Time to answer")
7777

78+
hide_status = env_vars.hide_status # Check the new attribute
79+
if not hide_status:
80+
columns.append("Status") # Add the 'status' column
81+
7882
enable_time_in_draft = env_vars.draft_pr_tracking
7983
if enable_time_in_draft:
8084
columns.append("Time in draft")
@@ -232,6 +236,8 @@ def write_to_markdown(
232236
file.write(f" {issue.label_metrics[label]} |")
233237
if "Created At" in columns:
234238
file.write(f" {issue.created_at} |")
239+
if "Status" in columns: # Check if 'Status' column is to be displayed
240+
file.write(f" {issue.status} |") # Write the status of the issue
235241
file.write("\n")
236242
file.write(
237243
"\n_This report was generated with the \
@@ -324,6 +330,8 @@ def write_overall_metrics_tables(
324330
f"| {stats_time_in_labels['med'][label]} "
325331
f"| {stats_time_in_labels['90p'][label]} |\n"
326332
)
333+
if "Status" in columns: # Add logic for the 'status' column
334+
file.write("| Status | | | |\n")
327335

328336
file.write("\n")
329337
# Write count stats to a separate table

test_assignee_functionality.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,34 @@ def test_get_non_hidden_columns_hides_both_assignee_and_author(self):
7575
self.assertNotIn("Assignee", columns)
7676
self.assertNotIn("Author", columns)
7777

78+
@patch.dict(
79+
os.environ,
80+
{
81+
"GH_TOKEN": "test_token",
82+
"SEARCH_QUERY": "is:issue is:open repo:user/repo",
83+
"HIDE_STATUS": "false",
84+
},
85+
clear=True,
86+
)
87+
def test_get_non_hidden_columns_includes_status_by_default(self):
88+
"""Test that status column is included by default."""
89+
columns = get_non_hidden_columns(labels=None)
90+
self.assertIn("Status", columns)
91+
92+
@patch.dict(
93+
os.environ,
94+
{
95+
"GH_TOKEN": "test_token",
96+
"SEARCH_QUERY": "is:issue is:open repo:user/repo",
97+
"HIDE_STATUS": "true",
98+
},
99+
clear=True,
100+
)
101+
def test_get_non_hidden_columns_hides_status_when_env_set(self):
102+
"""Test that status column is hidden when HIDE_STATUS is true."""
103+
columns = get_non_hidden_columns(labels=None)
104+
self.assertNotIn("Status", columns)
105+
78106
def test_assignee_column_position(self):
79107
"""Test that assignee column appears before author column."""
80108
with patch.dict(

0 commit comments

Comments
 (0)