13
13
Searches for issues in a GitHub repository that match the given search query.
14
14
auth_to_github() -> github3.GitHub: Connect to GitHub API with token authentication.
15
15
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]:
17
17
Calculate the metrics for each issue in a list of GitHub issues.
18
18
get_owner(search_query: str) -> Union[str, None]]:
19
19
Get the owner from the search query.
41
41
)
42
42
43
43
44
- def get_env_vars () -> tuple [str , str ]:
44
+ def get_env_vars () -> tuple [str , str , List [ str ] ]:
45
45
"""
46
46
Get the environment variables for use in the script.
47
47
48
48
Returns:
49
49
str: the search query used to filter issues, prs, and discussions
50
50
str: the github token used to authenticate to github.com
51
+ List[str]: a list of users to ignore when calculating metrics
51
52
"""
52
53
search_query = os .getenv ("SEARCH_QUERY" )
53
54
if not search_query :
@@ -57,7 +58,13 @@ def get_env_vars() -> tuple[str, str]:
57
58
if not token :
58
59
raise ValueError ("GITHUB_TOKEN environment variable not set" )
59
60
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
61
68
62
69
63
70
def search_issues (
@@ -125,6 +132,7 @@ def get_per_issue_metrics(
125
132
issues : Union [List [dict ], List [github3 .search .IssueSearchResult ]], # type: ignore
126
133
discussions : bool = False ,
127
134
labels : Union [List [str ], None ] = None ,
135
+ ignore_users : List [str ] = [],
128
136
) -> tuple [List , int , int ]:
129
137
"""
130
138
Calculate the metrics for each issue/pr/discussion in a list provided.
@@ -135,6 +143,7 @@ def get_per_issue_metrics(
135
143
discussions (bool, optional): Whether the issues are discussions or not.
136
144
Defaults to False.
137
145
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.
138
147
139
148
Returns:
140
149
tuple[List[IssueWithMetrics], int, int]: A tuple containing a
@@ -157,7 +166,7 @@ def get_per_issue_metrics(
157
166
None ,
158
167
)
159
168
issue_with_metrics .time_to_first_response = measure_time_to_first_response (
160
- None , issue
169
+ None , issue , ignore_users
161
170
)
162
171
issue_with_metrics .time_to_answer = measure_time_to_answer (issue )
163
172
if issue ["closedAt" ]:
@@ -175,7 +184,7 @@ def get_per_issue_metrics(
175
184
None ,
176
185
)
177
186
issue_with_metrics .time_to_first_response = measure_time_to_first_response (
178
- issue , None
187
+ issue , None , ignore_users
179
188
)
180
189
if labels :
181
190
issue_with_metrics .label_metrics = get_label_metrics (issue , labels )
@@ -238,6 +247,7 @@ def main():
238
247
env_vars = get_env_vars ()
239
248
search_query = env_vars [0 ]
240
249
token = env_vars [1 ]
250
+ ignore_users = env_vars [2 ]
241
251
242
252
# Get the repository owner and name from the search query
243
253
owner = get_owner (search_query )
@@ -280,6 +290,7 @@ def main():
280
290
issues ,
281
291
discussions = "type:discussions" in search_query ,
282
292
labels = labels ,
293
+ ignore_users = ignore_users ,
283
294
)
284
295
285
296
average_time_to_first_response = get_average_time_to_first_response (
0 commit comments