[IMP] add load info page

This commit is contained in:
Xavier-Do 2022-07-25 11:54:26 +02:00 committed by Christophe Monniez
parent a52c14957e
commit 9fb7e94de9
6 changed files with 104 additions and 21 deletions

View File

@ -508,7 +508,8 @@ class Runbot(Controller):
request.env.cr.execute("SELECT build_id, values FROM runbot_build_stat WHERE build_id IN %s AND category = %s", [tuple(builds.ids), key_category]) # read manually is way faster than using orm
res = {}
for (build_id, values) in request.env.cr.fetchall():
res.setdefault(parents[build_id], {}).update(values)
if values:
res.setdefault(parents[build_id], {}).update(values)
# we need to update here to manage the post install case: we want to combine stats from all post_install childrens.
return res
@ -525,3 +526,23 @@ class Runbot(Controller):
}
return request.render("runbot.modules_stats", context)
@route(['/runbot/load_info'], type='http', auth="user", website=True, sitemap=False)
def load_infos(self, **post):
build_by_bundle = {}
for build in request.env['runbot.build'].search([('local_state', 'in', ('pending', 'testing'))], order='id'):
build_by_bundle.setdefault(build.params_id.create_batch_id.bundle_id, []).append(build)
build_by_bundle = list(build_by_bundle.items())
build_by_bundle.sort(key=lambda x: -len(x[1]))
pending_count, level, scheduled_count = self._pending()
context = {
'build_by_bundle': build_by_bundle,
'pending_total': pending_count,
'pending_level': level,
'scheduled_count': scheduled_count,
'hosts_data': request.env['runbot.host'].search([('assigned_only', '=', False)]),
}
return request.render("runbot.load_info", context)

View File

@ -24,12 +24,14 @@ class BuildStatRegex(models.Model):
_name = "runbot.build.stat.regex"
_description = "Statistics regex"
_order = 'sequence,id'
name = fields.Char("Key Name")
regex = fields.Char("Regular Expression")
description = fields.Char("Description")
generic = fields.Boolean('Generic', help='Executed when no regex on the step', default=True)
config_step_ids = fields.Many2many('runbot.build.config.step', string='Config Steps')
sequence = fields.Integer('Sequence')
@api.constrains("name", "regex")
def _check_regex(self):

View File

@ -27,7 +27,10 @@ a {
a:hover {
color: #005452;
text-decoration: underline;
}
a.slots_infos:hover {
text-decoration: none;
}

View File

@ -226,5 +226,58 @@
</t>
</template>
<template id="runbot.load_info">
<t t-call='runbot.layout'>
<div class="container-fluid frontend">
<div class="row">
<div class="col-md-12">
<t t-call="runbot.slots_infos"/>
</div>
</div>
<div t-foreach="build_by_bundle" t-as="bundle_builds" class="row bundle_row">
<t t-set="bundle" t-value="bundle_builds[0]"/>
<t t-set="builds" t-value="bundle_builds[1]"/>
<div class="col-md-3 col-lg-2 cell">
<div class="one_line">
<i t-if="bundle.sticky" class="fa fa-star" style="color: #f0ad4e" />
<a t-attf-href="/runbot/bundle/#{bundle.id}" title="View Bundle">
<b t-esc="bundle.name"/>
</a>
</div>
<div class="badge badge-info" t-out="len(builds)"/>
</div>
<div class="col-md-9 col-lg-10">
<div class="table-responsive">
<table class="table table-condensed">
<t t-foreach="builds" t-as="build">
<t t-set="rowclass">
<t t-call="runbot.build_class">
<t t-set="build" t-value="build"/>
</t>
</t>
<tr t-attf-class="bg-{{rowclass.strip()}}-light{{'line-through' if build.orphan_result else ''}}">
<td> Batch: <a t-attf-href="/runbot/batch/{{build.params_id.create_batch_id.id}}"><t t-out="build.params_id.create_batch_id.id"/></a></td>
<td><a t-attf-href="/runbot/build/{{build.id}}"><t t-out="build.parent_path"/></a></td>
<td t-out="build.local_state"/>
<td t-out="build.host"/>
<td t-out="build.config_id.name"/>
<td>
<t t-call="runbot.build_button">
<t t-set="bu" t-value="build"/>
<t t-set="klass" t-value="'btn-group-ssm'"/>
</t>
</td>
</tr>
</t>
</table>
</div>
</div>
</div>
</div>
</t>
</template>
</data>
</odoo>

View File

@ -152,25 +152,27 @@
</template>
<template id="runbot.slots_infos" name="Hosts slot nb pending/testing/slots">
<span t-attf-class="badge badge-{{pending_level}}">
Pending:
<t t-esc="pending_total"/>
</span>
<t t-set="testing" t-value="hosts_data._total_testing()"/>
<t t-set="workers" t-value="hosts_data._total_workers()"/>
<t t-set="klass">success</t>
<t t-if="not workers" t-set="klass">danger</t>
<t t-else="">
<t t-if="int(testing)/workers > 0" t-set="klass">info</t>
<t t-if="int(testing)/workers > 0.75" t-set="klass">warning</t>
<t t-if="int(testing)/workers >= 1" t-set="klass">danger</t>
</t>
<span t-attf-class="badge badge-{{klass}}">
Testing:
<t t-esc="testing"/>
/
<t t-esc="workers"/>
</span>
<a href="/runbot/load_info" class="slots_infos">
<span t-attf-class="badge badge-{{pending_level}}">
Pending:
<t t-esc="pending_total"/>
</span>
<t t-set="testing" t-value="hosts_data._total_testing()"/>
<t t-set="workers" t-value="hosts_data._total_workers()"/>
<t t-set="klass">success</t>
<t t-if="not workers" t-set="klass">danger</t>
<t t-else="">
<t t-if="int(testing)/workers > 0" t-set="klass">info</t>
<t t-if="int(testing)/workers > 0.75" t-set="klass">warning</t>
<t t-if="int(testing)/workers >= 1" t-set="klass">danger</t>
</t>
<span t-attf-class="badge badge-{{klass}}">
Testing:
<t t-esc="testing"/>
/
<t t-esc="workers"/>
</span>
</a>
</template>
<template id="runbot.slot_button">

View File

@ -11,6 +11,7 @@
<field name="regex" placeholder="odoo.addons.(?P&lt;key&gt;.+) tested in .+, (?P&lt;value&gt;\d+) queries"/>
<field name="generic"/>
<field name="description"/>
<field name="sequence"/>
</group>
</sheet>
</form>
@ -26,6 +27,7 @@
<field name="generic"/>
<field name="description"/>
<field name="regex"/>
<field name="sequence" widget="handle"/>
</tree>
</field>
</record>