mirror of
https://github.com/odoo/runbot.git
synced 2025-03-24 11:55:49 +07:00

Fix outstanding query to make a positive `state` filtering, instead of negative, matching 3b52b1aace8674259812a76b1566260937dbcacb. Also manually create a map of stagings (grouped by branch) sharing a single prefetch set. For odoo the mergebot home page has 12 branches in the odoo project and 8 in spreadsheet, 6 stagings each. This means 120 queries to retrieve all the heads (Odoo stagings have 5 heads and spreadsheet have 1, but that seems immaterial). By fixing `_compute_statuses` and creating a single prefetch set for all stagings of all branches we can fetch all the commits in a single query instead of 120.
237 lines
12 KiB
XML
237 lines
12 KiB
XML
<odoo>
|
|
<template id="alerts" inherit_id="runbot_merge.alerts">
|
|
<xpath expr="//div[@id='alerts']">
|
|
<t t-set="fpcron" t-value="env(user=1).ref('forwardport.port_forward')"/>
|
|
<div t-if="not fpcron.active" class="alert alert-warning col-12" role="alert">
|
|
Forward-port is disabled, merged pull requests will not be forward-ported.
|
|
</div>
|
|
</xpath>
|
|
<!-- key block (hopefully) -->
|
|
<xpath expr="//div[@id='alerts']" position="inside">
|
|
<t t-if="env['runbot_merge.pull_requests'].check_access_rights('read', False)">
|
|
<t t-set="outstanding" t-value="env['runbot_merge.pull_requests'].search_count([
|
|
('state', 'in', ['opened', 'validated', 'approved', 'ready', 'error']),
|
|
('source_id.merge_date', '<', datetime.datetime.now() - relativedelta(days=3)),
|
|
])"/>
|
|
<div t-if="outstanding != 0" class="alert col-md-12 alert-warning mb-0">
|
|
<a href="/forwardport/outstanding">
|
|
<t t-esc="outstanding"/> outstanding forward-ports
|
|
</a>
|
|
</div>
|
|
</t>
|
|
</xpath>
|
|
</template>
|
|
|
|
<template id="pr_background">
|
|
<t t-if="p.state == 'merged'">bg-success</t>
|
|
<t t-elif="p.state == 'closed'">bg-light</t>
|
|
<t t-elif="p.state == 'error'">bg-danger</t>
|
|
<t t-else="">bg-warning</t>
|
|
</template>
|
|
|
|
<template id="outstanding" name="Outstanding forward ports">
|
|
<t t-call="website.layout">
|
|
<div id="wrap" class="oe_structure oe_empty"><div class="container-fluid">
|
|
<div class="alert bg-light outstanding-partners">
|
|
<t t-foreach="groups" t-as="group">
|
|
<span>
|
|
<t t-if="group == current_group">
|
|
<span class="bg-primary" t-out="group.display_name"/>
|
|
<a t-att-href="link()" class="btn fa fa-times p-0"/>
|
|
</t>
|
|
<t t-else="">
|
|
<a t-att-href="link(group=group.id, partner=0)" t-out="group.display_name"/>
|
|
</t>
|
|
</span>
|
|
</t>
|
|
</div>
|
|
<div class="alert bg-light outstanding-partners">
|
|
<t t-foreach="culprits" t-as="culprit">
|
|
<t t-set="approved" t-value="outstanding_per_reviewer[culprit]"/>
|
|
<t t-set="created" t-value="outstanding_per_author[culprit]"/>
|
|
<a t-att-href="link(partner=culprit.id)"
|
|
t-attf-title="approved {{approved}}, created {{created}}"
|
|
><t t-out="culprit.display_name"/>:
|
|
<t t-if="approved" t-out="approved"/>
|
|
<t t-if="approved and created"> + </t>
|
|
<t t-if="created" t-out="created"/>
|
|
</a>
|
|
</t>
|
|
</div>
|
|
<t t-if="not single">
|
|
by
|
|
<span class="btn-group btn-group-toggle">
|
|
<a t-att-href="link(authors=1, reviewers=1)"
|
|
t-attf-class="btn btn-sm btn-secondary {{'active' if authors and reviewers else ''}}">
|
|
both
|
|
</a>
|
|
<a t-att-href="link(authors=1, reviewers=0)"
|
|
t-attf-class="btn btn-sm btn-secondary {{'active' if authors and not reviewers else ''}}">
|
|
creators
|
|
</a>
|
|
<a t-att-href="link(reviewers=1, authors=0)"
|
|
t-attf-class="btn btn-sm btn-secondary {{'active' if reviewers and not authors else ''}}">
|
|
reviewers
|
|
</a>
|
|
</span>
|
|
</t>
|
|
<h1>List of pull requests with outstanding forward ports</h1>
|
|
<h2 t-if="single">
|
|
for <span t-field="single.display_name" t-attf-title="@{{single.github_login}}"/>
|
|
<a t-att-href="link(partner=0)" title="All Users" class="btn fa fa-times"/>
|
|
|
|
<span class="btn-group btn-group-toggle">
|
|
<a t-att-href="link(authors=1, reviewers=1)"
|
|
t-attf-class="btn btn-sm btn-secondary {{'active' if authors and reviewers else ''}}">
|
|
both
|
|
</a>
|
|
<a t-att-href="link(authors=1, reviewers=0)"
|
|
t-attf-class="btn btn-sm btn-secondary {{'active' if authors and not reviewers else ''}}">
|
|
created
|
|
</a>
|
|
<a t-att-href="link(reviewers=1, authors=0)"
|
|
t-attf-class="btn btn-sm btn-secondary {{'active' if reviewers and not authors else ''}}">
|
|
reviewed
|
|
</a>
|
|
</span>
|
|
</h2>
|
|
|
|
<dl><t t-foreach="outstanding" t-as="x">
|
|
<t t-set="source" t-value="x['source']"/>
|
|
<t t-if="not single or source.reviewed_by == single or source.author == single">
|
|
<dt>
|
|
<a t-att-href="source.url"><span t-field="source.display_name"/></a>
|
|
created by <span t-field="source.author.display_name"
|
|
t-attf-title="@{{source.author.github_login}}"/>
|
|
merged <span t-field="source.merge_date"
|
|
t-options="{'widget': 'relative'}"
|
|
t-att-title="source.merge_date"/>
|
|
by <span t-field="source.reviewed_by.display_name"
|
|
t-attf-title="@{{source.reviewed_by.github_login}}"/>
|
|
</dt>
|
|
<dd>
|
|
Outstanding forward-ports:
|
|
<ul>
|
|
<li t-foreach="x['prs']" t-as="p">
|
|
<a t-att-href="p.url"><span t-field="p.display_name"/></a>
|
|
(<span t-field="p.state"/>)
|
|
targeting <span t-field="p.target.name"/>
|
|
</li>
|
|
</ul>
|
|
</dd>
|
|
</t>
|
|
</t></dl>
|
|
</div></div>
|
|
</t>
|
|
</template>
|
|
|
|
<template id="view_pull_request" inherit_id="runbot_merge.view_pull_request">
|
|
<xpath expr="//dl[hasclass('runbot-merge-fields')]" position="inside">
|
|
<t t-if="pr.state == 'merged'">
|
|
<dt>merged</dt>
|
|
<dd>
|
|
<span t-field="pr.merge_date" t-options="{'widget': 'relative'}"
|
|
t-att-title="pr.merge_date"/>
|
|
by <span t-field="pr.reviewed_by.display_name"
|
|
t-attf-title="@{{pr.reviewed_by.github_login}}"/>
|
|
</dd>
|
|
</t>
|
|
<t t-if="pr.source_id">
|
|
<dt>forward-port of</dt>
|
|
<dd>
|
|
<a t-att-href="pr.source_id.url">
|
|
<span t-field="pr.source_id.display_name"/>
|
|
</a>
|
|
<span t-if="not pr.parent_id"
|
|
class="badge badge-danger user-select-none"
|
|
title="A detached PR behaves like a non-forward-port, it has to be approved via the mergebot, this is usually caused by the forward-port having been in conflict or updated.">
|
|
DETACHED (<span t-out="pr.detach_reason" style="white-space: pre-wrap;"/>)
|
|
</span>
|
|
</dd>
|
|
</t>
|
|
<t t-if="pr.forwardport_ids">
|
|
<dt>forward-ports</dt>
|
|
<dd><ul>
|
|
<t t-foreach="pr.forwardport_ids" t-as="p">
|
|
<t t-set="bgsignal"><t t-call="forwardport.pr_background"/></t>
|
|
<li t-att-class="bgsignal">
|
|
<a t-att-href="p.url"><span t-field="p.display_name"/></a>
|
|
targeting <span t-field="p.target.name"/>
|
|
</li>
|
|
</t>
|
|
</ul></dd>
|
|
</t>
|
|
</xpath>
|
|
</template>
|
|
|
|
<record model="ir.ui.view" id="project">
|
|
<field name="name">Show forwardport project fields</field>
|
|
<field name="inherit_id" ref="runbot_merge.runbot_merge_form_project"/>
|
|
<field name="model">runbot_merge.project</field>
|
|
<field name="arch" type="xml">
|
|
<xpath expr="//sheet/group[2]" position="after">
|
|
<group string="Forwardport Configuration">
|
|
<group>
|
|
<field string="Token" name="fp_github_token"/>
|
|
</group>
|
|
<group>
|
|
<field string="Bot Name" name="fp_github_name"/>
|
|
<field string="Bot Email" name="fp_github_email"/>
|
|
</group>
|
|
</group>
|
|
</xpath>
|
|
<xpath expr="//field[@name='repo_ids']/tree" position="inside">
|
|
<field string="FP remote" name="fp_remote_target"
|
|
help="Repository where forward port branches will be created"
|
|
/>
|
|
</xpath>
|
|
</field>
|
|
</record>
|
|
|
|
<record model="ir.ui.view" id="repository">
|
|
<field name="name">Show forwardport repository fields</field>
|
|
<field name="inherit_id" ref="runbot_merge.form_repository"/>
|
|
<field name="model">runbot_merge.repository</field>
|
|
<field name="arch" type="xml">
|
|
<field name="branch_filter" position="after">
|
|
<field string="FP remote" name="fp_remote_target"
|
|
help="Repository where forward port branches will be created"/>
|
|
</field>
|
|
</field>
|
|
</record>
|
|
|
|
<record model="ir.ui.view" id="pr">
|
|
<field name="name">Show forwardport PR fields</field>
|
|
<field name="inherit_id" ref="runbot_merge.runbot_merge_form_prs"/>
|
|
<field name="model">runbot_merge.pull_requests</field>
|
|
<field name="arch" type="xml">
|
|
<xpath expr="//field[@name='state']" position="after">
|
|
<field name="merge_date" attrs="{'invisible': [('state', '!=', 'merged')]}"/>
|
|
</xpath>
|
|
<xpath expr="//sheet/group[2]" position="after">
|
|
<separator string="Forward Port" attrs="{'invisible': [('source_id', '=', False)]}"/>
|
|
<group attrs="{'invisible': [('source_id', '!=', False)]}">
|
|
<group>
|
|
<field string="Policy" name="fw_policy"/>
|
|
</group>
|
|
</group>
|
|
<group attrs="{'invisible': [('source_id', '=', False)]}">
|
|
<group>
|
|
<field string="Original PR" name="source_id"/>
|
|
</group>
|
|
<group attrs="{'invisible': [('parent_id', '=', False)]}">
|
|
<field name="parent_id"/>
|
|
</group>
|
|
<group colspan="4" attrs="{'invisible': [('parent_id', '!=', False)]}">
|
|
<field string="Detached because" name="detach_reason" readonly="1"/>
|
|
</group>
|
|
<group>
|
|
<field string="Forward ported up to" name="limit_id"/>
|
|
</group>
|
|
</group>
|
|
</xpath>
|
|
</field>
|
|
</record>
|
|
|
|
</odoo>
|