1313 Searches for issues in a GitHub repository that match the given search query.
1414 auth_to_github() -> github3.GitHub: Connect to GitHub API with token authentication.
1515 get_per_issue_metrics(issues: Union[List[dict], List[github3.issues.Issue]],
16- discussions: bool = False) -> tuple[List, int, int]:
16+ discussions: bool = False), labels: Union[List[str], None] = None, ignore_users: List[str] = [] -> tuple[List, int, int]:
1717 Calculate the metrics for each issue in a list of GitHub issues.
1818 get_owner(search_query: str) -> Union[str, None]]:
1919 Get the owner from the search query.
4141)
4242
4343
44- def get_env_vars () -> tuple [str , str ]:
44+ def get_env_vars () -> tuple [str , str , List [ str ] ]:
4545 """
4646 Get the environment variables for use in the script.
4747
4848 Returns:
4949 str: the search query used to filter issues, prs, and discussions
5050 str: the github token used to authenticate to github.com
51+ List[str]: a list of users to ignore when calculating metrics
5152 """
5253 search_query = os .getenv ("SEARCH_QUERY" )
5354 if not search_query :
@@ -57,7 +58,13 @@ def get_env_vars() -> tuple[str, str]:
5758 if not token :
5859 raise ValueError ("GITHUB_TOKEN environment variable not set" )
5960
60- return search_query , token
61+ ignore_users = os .getenv ("IGNORE_USERS" )
62+ if ignore_users :
63+ ignore_users = ignore_users .split ("," )
64+ else :
65+ ignore_users = []
66+
67+ return search_query , token , ignore_users
6168
6269
6370def search_issues (
@@ -125,6 +132,7 @@ def get_per_issue_metrics(
125132 issues : Union [List [dict ], List [github3 .search .IssueSearchResult ]], # type: ignore
126133 discussions : bool = False ,
127134 labels : Union [List [str ], None ] = None ,
135+ ignore_users : List [str ] = [],
128136) -> tuple [List , int , int ]:
129137 """
130138 Calculate the metrics for each issue/pr/discussion in a list provided.
@@ -135,6 +143,7 @@ def get_per_issue_metrics(
135143 discussions (bool, optional): Whether the issues are discussions or not.
136144 Defaults to False.
137145 labels (List[str]): A list of labels to measure time spent in. Defaults to empty list.
146+ ignore_users (List[str]): A list of users to ignore when calculating metrics.
138147
139148 Returns:
140149 tuple[List[IssueWithMetrics], int, int]: A tuple containing a
@@ -157,7 +166,7 @@ def get_per_issue_metrics(
157166 None ,
158167 )
159168 issue_with_metrics .time_to_first_response = measure_time_to_first_response (
160- None , issue
169+ None , issue , ignore_users
161170 )
162171 issue_with_metrics .time_to_answer = measure_time_to_answer (issue )
163172 if issue ["closedAt" ]:
@@ -175,7 +184,7 @@ def get_per_issue_metrics(
175184 None ,
176185 )
177186 issue_with_metrics .time_to_first_response = measure_time_to_first_response (
178- issue , None
187+ issue , None , ignore_users
179188 )
180189 if labels :
181190 issue_with_metrics .label_metrics = get_label_metrics (issue , labels )
@@ -238,6 +247,7 @@ def main():
238247 env_vars = get_env_vars ()
239248 search_query = env_vars [0 ]
240249 token = env_vars [1 ]
250+ ignore_users = env_vars [2 ]
241251
242252 # Get the repository owner and name from the search query
243253 owner = get_owner (search_query )
@@ -280,6 +290,7 @@ def main():
280290 issues ,
281291 discussions = "type:discussions" in search_query ,
282292 labels = labels ,
293+ ignore_users = ignore_users ,
283294 )
284295
285296 average_time_to_first_response = get_average_time_to_first_response (
0 commit comments