@@ -134,7 +134,8 @@ def get_activity(
134134 -------
135135 query_data : pandas DataFrame
136136 A munged collection of data returned from your query. This
137- will be a combination of issues and PRs.
137+ will be a combination of issues and PRs. The DataFrame has a
138+ `bot_users` attribute containing the set of detected bot usernames.
138139 """
139140
140141 org , repo = _parse_target (target )
@@ -206,13 +207,16 @@ def get_activity(
206207 # Query for both opened and closed issues/PRs in this window
207208 print (f"Running search query:\n { search_query } \n \n " , file = sys .stderr )
208209 query_data = []
210+ all_bot_users = set ()
209211 for activity_type in ["created" , "closed" ]:
210212 ii_search_query = (
211213 search_query + f" { activity_type } :{ since_dt_str } ..{ until_dt_str } "
212214 )
213215 qu = GitHubGraphQlQuery (ii_search_query , auth = auth )
214216 qu .request ()
215217 query_data .append (qu .data )
218+ # Collect bot users from each query
219+ all_bot_users .update (qu .bot_users )
216220
217221 query_data = (
218222 pd .concat (query_data ).drop_duplicates (subset = ["id" ]).reset_index (drop = True )
@@ -223,9 +227,12 @@ def get_activity(
223227 query_data .until_dt_str = until_dt_str
224228 query_data .since_is_git_ref = since_is_git_ref
225229 query_data .until_is_git_ref = until_is_git_ref
230+ # Restore bot_users in attrs (lost during concat)
231+ query_data .attrs ["bot_users" ] = all_bot_users
226232
227233 if cache :
228234 _cache_data (query_data , cache )
235+
229236 return query_data
230237
231238
@@ -462,7 +469,7 @@ def generate_activity_md(
462469 data ["contributors" ] = [[]] * len (data )
463470
464471 # Get bot users from GraphQL data (stored in DataFrame attrs)
465- bot_users = data .attrs . get ( "bot_users" , set ())
472+ bot_users = data .attrs [ "bot_users" ]
466473
467474 def ignored_user (username ):
468475 if username in bot_users :
@@ -490,12 +497,19 @@ def filter_ignored(userlist):
490497 # - merger
491498 # - reviewers
492499
493- item_contributors .author = row .author
500+ # Only add author if they're not a bot
501+ if not ignored_user (row .author ):
502+ item_contributors .author = row .author
494503
495504 if row .kind == "pr" :
496505 for committer in filter_ignored (row .committers ):
497506 item_contributors .add (committer )
498- if row .mergedBy and row .mergedBy != row .author :
507+ # Only add merger if they're not a bot and not the author
508+ if (
509+ row .mergedBy
510+ and row .mergedBy != row .author
511+ and not ignored_user (row .mergedBy )
512+ ):
499513 item_contributors .add (row .mergedBy )
500514 for reviewer in filter_ignored (row .reviewers ):
501515 item_contributors .add (reviewer )
0 commit comments