[IMP] runbot: add a build search page

Quick prototype to find similar builds, especially usefull for nighlty
to list history of some subbuild.
This commit is contained in:
Xavier-Do 2022-01-18 11:04:24 +01:00 committed by Christophe Monniez
parent dde70ffeb2
commit de84882a07
3 changed files with 82 additions and 0 deletions

View File

@ -304,6 +304,31 @@ class Runbot(Controller):
}
return request.render("runbot.build", context)
@route([
'/runbot/build/search',
], website=True, auth='public', type='http', sitemap=False)
def builds(self, **kwargs):
domain = []
for key in ('config_id', 'version_id', 'project_id', 'trigger_id', 'create_batch_id.bundle_id', 'create_batch_id'): # allowed params
value = kwargs.get(key)
if value:
domain.append((f'params_id.{key}', '=', int(value)))
for key in ('global_state', 'local_state', 'global_result', 'local_result'):
value = kwargs.get(key)
if value:
domain.append((f'{key}', '=', value))
for key in ('description',):
if key in kwargs:
domain.append((f'{key}', 'ilike', kwargs.get(key)))
context = {
'builds': request.env['runbot.build'].search(domain, limit=100),
}
return request.render('runbot.build_search', context)
@route([
'/runbot/branch/<model("runbot.branch"):branch>',
], website=True, auth='public', type='http', sitemap=False)

View File

@ -330,5 +330,58 @@
</div>
</t>
</template>
<template id="runbot.build_search">
<t t-call='runbot.layout'>
<div class="row">
<div class="col-md-12">
<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>
<t t-esc="build.create_date"/>
</td>
<td>
<a t-attf-href="/runbot/{{'batch/%s/' % from_batch.id if from_batch else ''}}build/{{build.id}}">
<t t-esc="build.id"/>
</a>
</td>
<td>
<t t-if="build.description">
<t t-raw="build.md_description" />
</t>
</td>
<td>
<t t-if="build.global_state in ['testing', 'waiting']">
<i class="fa fa-spinner fa-spin"/>
<t t-esc="build.global_state"/>
</t>
</td>
<td>
<span t-esc="build.params_id.config_id.name"/>
</td>
<td>
<span t-esc="build.params_id.version_id.name"/>
</td>
<td>
<span t-esc="build.get_formated_build_time()"/>
</td>
<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>
</t>
</template>
</data>
</odoo>

View File

@ -306,6 +306,10 @@
</t>
<t groups="runbot.group_runbot_admin">
<div class="dropdown-divider"/>
<a class="dropdown-item" t-attf-href="/runbot/build/search?config_id={{bu.params_id.config_id.id}}&amp;trigger_id={{bu.params_id.trigger_id.id}}&amp;version_id={{bu.params_id.version_id.id}}&amp;create_batch_id.bundle_id={{bu.params_id.create_batch_id.bundle_id.id}}&amp;description={{bu.description or ''}}">
<i class="fa fa-search"/>
Find similar builds
</a>
<a class="dropdown-item" t-attf-href="/web/#id={{bu['id']}}&amp;view_type=form&amp;model=runbot.build" target="new">
<i class="fa fa-list"/>
View in backend