[FIX] forwardport: count next to users should be the fwport

Previously it would count the number of source PRs with outstanding
forward ports, which is not the count from the home page so that was
confusing.

Also add counts next to the groups, so teams can be identified at a
glance.

And finally outline the current user in the list, so they can find
themselves faster when they're not one of the top entries.
This commit is contained in:
Xavier Morel 2024-06-28 08:18:34 +02:00
parent eb23a8c083
commit 318e55337c
2 changed files with 19 additions and 6 deletions

View File

@ -66,18 +66,23 @@ class Dashboard(MergebotDashboard):
('state', 'in', ['opened', 'validated', 'approved', 'ready', 'error']), ('state', 'in', ['opened', 'validated', 'approved', 'ready', 'error']),
('source_id', 'in', PullRequests._search(source_filter)), ('source_id', 'in', PullRequests._search(source_filter)),
]) ])
outstanding_per_group = collections.Counter()
outstanding_per_author = collections.Counter() outstanding_per_author = collections.Counter()
outstanding_per_reviewer = collections.Counter() outstanding_per_reviewer = collections.Counter()
outstandings = [] outstandings = []
for source in outstanding.mapped('source_id').sorted('merge_date'): for source in outstanding.mapped('source_id').sorted('merge_date'):
prs = source.forwardport_ids.filtered(lambda p: p.state not in ['merged', 'closed'])
outstandings.append({ outstandings.append({
'source': source, 'source': source,
'prs': source.forwardport_ids.filtered(lambda p: p.state not in ['merged', 'closed']), 'prs': prs,
}) })
if authors: if authors:
outstanding_per_author[source.author] += 1 outstanding_per_author[source.author] += len(prs)
outstanding_per_group[source.author.commercial_partner_id] += len(prs)
if reviewers and source: if reviewers and source:
outstanding_per_reviewer[source.reviewed_by] += 1 outstanding_per_reviewer[source.reviewed_by] += len(prs)
outstanding_per_group[source.reviewed_by.commercial_partner_id] += len(prs)
culprits = Partners.browse(p.id for p, _ in (outstanding_per_reviewer + outstanding_per_author).most_common()) culprits = Partners.browse(p.id for p, _ in (outstanding_per_reviewer + outstanding_per_author).most_common())
return request.render('forwardport.outstanding', { return request.render('forwardport.outstanding', {
@ -89,6 +94,7 @@ class Dashboard(MergebotDashboard):
'current_group': group, 'current_group': group,
'outstanding_per_author': outstanding_per_author, 'outstanding_per_author': outstanding_per_author,
'outstanding_per_reviewer': outstanding_per_reviewer, 'outstanding_per_reviewer': outstanding_per_reviewer,
'outstanding_per_group': outstanding_per_group,
'outstanding': outstandings, 'outstanding': outstandings,
'link': link, 'link': link,
}) })

View File

@ -36,11 +36,17 @@
<t t-foreach="groups" t-as="group"> <t t-foreach="groups" t-as="group">
<span> <span>
<t t-if="group == current_group"> <t t-if="group == current_group">
<span class="bg-primary" t-out="group.display_name"/> <span class="bg-primary">
<t t-out="group.display_name"/>
(<t t-out="outstanding_per_group[group]"/>)
</span>
<a t-att-href="link()" class="btn fa fa-times p-0"/> <a t-att-href="link()" class="btn fa fa-times p-0"/>
</t> </t>
<t t-else=""> <t t-else="">
<a t-att-href="link(group=group.id, partner=0)" t-out="group.display_name"/> <a t-att-href="link(group=group.id, partner=0)">
<t t-out="group.display_name"/>
(<t t-out="outstanding_per_group[group]"/>)
</a>
</t> </t>
</span> </span>
</t> </t>
@ -51,7 +57,8 @@
<t t-set="created" t-value="outstanding_per_author[culprit]"/> <t t-set="created" t-value="outstanding_per_author[culprit]"/>
<a t-att-href="link(partner=culprit.id)" <a t-att-href="link(partner=culprit.id)"
t-attf-title="approved {{approved}}, created {{created}}" t-attf-title="approved {{approved}}, created {{created}}"
><t t-out="culprit.display_name"/>: t-att-class="'bg-primary' if culprit == env.user.partner_id else None"
><t t-out="culprit.name"/>:
<t t-if="approved" t-out="approved"/> <t t-if="approved" t-out="approved"/>
<t t-if="approved and created"> + </t> <t t-if="approved and created"> + </t>
<t t-if="created" t-out="created"/> <t t-if="created" t-out="created"/>