From 63a4916d002a9408bf75525753ee8daf84f52a12 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 24 Jan 2025 15:20:19 +0100 Subject: [PATCH] [FIX] forwardport: avoid double counting PRs for teams In the case where both author and reviewer of a PR have the same team (which is very common e.g. self review or a team member approving your PR) then the `outstanding_per_group` entry would be incremented twice, leading to overcounting outstanding forward ports for the team. Fixes #801 --- forwardport/controllers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/forwardport/controllers.py b/forwardport/controllers.py index caa2103b..43f6eb89 100644 --- a/forwardport/controllers.py +++ b/forwardport/controllers.py @@ -79,10 +79,12 @@ class Dashboard(MergebotDashboard): }) if authors: outstanding_per_author[source.author] += len(prs) - outstanding_per_group[source.author.commercial_partner_id] += len(prs) - if reviewers and source: + if reviewers: outstanding_per_reviewer[source.reviewed_by] += len(prs) - outstanding_per_group[source.reviewed_by.commercial_partner_id] += len(prs) + + # if both the source and reviewer have the same team, don't count the PRs twice + for team in source.author.commercial_partner_id | source.reviewed_by.commercial_partner_id: + outstanding_per_group[team] += len(prs) culprits = Partners.browse(p.id for p, _ in (outstanding_per_reviewer + outstanding_per_author).most_common()) return request.render('forwardport.outstanding', {