@@ -44,25 +44,27 @@ def count_merged_prs_per_user(
4444 period_end : datetime ,
4545) -> dict [str , int ]:
4646 """Count merged PRs per verified GitHub user for the given period.
47-
48- Returns a dictionary mapping github_user to merged PR count.
47+
48+ Returns a dictionary mapping github_user (canonical from identity) to merged PR count.
4949 Only counts events for verified users in identity_mappings.
50+ Uses same case-insensitive normalization as repos_with_merged_pr_per_user.
5051 """
51- # Get all contributions since period_start
52+ identity_list = list (identity_mappings )
53+ github_lower_to_canonical = {m .github_user .strip ().lower (): m .github_user for m in identity_list }
54+ verified_lower = set (github_lower_to_canonical .keys ())
55+
5256 all_events = storage .list_contributions (period_start )
53-
54- # Filter to merged PRs in the period
55- verified_github_users = {mapping .github_user for mapping in identity_mappings }
5657 merged_pr_counts : dict [str , int ] = {}
57-
58+
5859 for event in all_events :
59- if (
60- event .event_type == "pr_merged"
61- and event .github_user in verified_github_users
62- and period_start <= event .created_at <= period_end
63- ):
64- merged_pr_counts [event .github_user ] = merged_pr_counts .get (event .github_user , 0 ) + 1
65-
60+ if event .event_type != "pr_merged" or not event .github_user :
61+ continue
62+ if period_start <= event .created_at <= period_end :
63+ event_gh_lower = event .github_user .strip ().lower ()
64+ if event_gh_lower in verified_lower :
65+ canonical = github_lower_to_canonical [event_gh_lower ]
66+ merged_pr_counts [canonical ] = merged_pr_counts .get (canonical , 0 ) + 1
67+
6668 return merged_pr_counts
6769
6870
0 commit comments