mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] runbot: add a public route for monitoring
This commit is contained in:
parent
6b88cb7688
commit
7e49b4cd2b
@ -13,6 +13,7 @@ from odoo.http import Controller, request, route
|
||||
from ..common import uniq_list, flatten, fqdn
|
||||
from odoo.osv import expression
|
||||
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
class Runbot(Controller):
|
||||
|
||||
@ -329,6 +330,38 @@ class Runbot(Controller):
|
||||
}
|
||||
return request.render(view_id if view_id else config.monitoring_view_id.id or "runbot.monitoring", qctx)
|
||||
|
||||
@route(['/runbot/config/<int:config_id>',
|
||||
'/runbot/config/<config_name>'], type='http', auth="public", website=True)
|
||||
def config(self, config_id=None, config_name=None, refresh=None, **kwargs):
|
||||
|
||||
if config_id:
|
||||
monitored_config_id = config_id
|
||||
else:
|
||||
config = request.env['runbot.build.config'].search([('name', '=', config_name)], limit=1)
|
||||
if config:
|
||||
monitored_config_id = config.id
|
||||
else:
|
||||
raise UserError('Config name not found')
|
||||
|
||||
readable_repos = request.env['runbot.repo'].search([])
|
||||
request.env.cr.execute("""SELECT DISTINCT ON (branch_id) branch_id, id FROM runbot_build
|
||||
WHERE config_id = %s
|
||||
AND global_state in ('running', 'done')
|
||||
AND branch_id in (SELECT id FROM runbot_branch where sticky='t' and repo_id in %s)
|
||||
AND local_state != 'duplicate'
|
||||
AND hidden = false
|
||||
ORDER BY branch_id ASC, id DESC""", [int(monitored_config_id), tuple(readable_repos.ids)])
|
||||
last_monitored = request.env['runbot.build'].browse([r[1] for r in request.env.cr.fetchall()])
|
||||
|
||||
config = request.env['runbot.build.config'].browse(monitored_config_id)
|
||||
qctx = {
|
||||
'config': config,
|
||||
'refresh': refresh,
|
||||
'last_monitored': last_monitored, # nightly
|
||||
'kwargs': kwargs
|
||||
}
|
||||
return request.render(config.monitoring_view_id.id or "runbot.config_monitoring", qctx)
|
||||
|
||||
@route(['/runbot/branch/<int:branch_id>', '/runbot/branch/<int:branch_id>/page/<int:page>'], website=True, auth='public', type='http')
|
||||
def branch_builds(self, branch_id=None, search='', page=1, limit=50, refresh='', **kwargs):
|
||||
""" list builds of a runbot branch """
|
||||
|
@ -120,6 +120,41 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="runbot.config_monitoring">
|
||||
<t t-call="runbot.frontend_no_nav">
|
||||
<t t-set="head">
|
||||
<t t-if="refresh">
|
||||
<meta http-equiv="refresh" t-att-content="refresh"/>
|
||||
</t>
|
||||
</t>
|
||||
<table>
|
||||
<tr t-foreach="last_monitored" t-as="build">
|
||||
<t t-set="build" t-value="build.real_build"/>
|
||||
<td>
|
||||
<t t-esc="build.repo_id.short_name"/>/<t t-esc="build.branch_id.branch_name"/>
|
||||
</td>
|
||||
<t t-if="build.local_result == 'ko'"><t t-set="klass">danger</t></t>
|
||||
<t t-if="build.local_result == 'warn'"><t t-set="klass">warning</t></t>
|
||||
<t t-if="build.local_result == 'ok'"><t t-set="klass">success</t></t>
|
||||
<t t-if="build.local_result == 'killed'"><t t-set="klass">killed</t></t>
|
||||
<td>
|
||||
<a t-attf-href='/runbot/build/{{build.id}}'><span t-attf-class="label label-{{klass}}"><t t-esc="build.config_id.name"/></span></a>
|
||||
</td>
|
||||
<td>
|
||||
<span t-foreach="build.children_ids.sorted(key=lambda c:c.config_id.name, reverse=True).filtered(lambda c: c.local_result != 'ok' and not c.orphan_result)" t-as="child">
|
||||
<t t-if="child.global_result == 'ko'"><t t-set="klass">danger</t></t>
|
||||
<t t-if="child.global_result == 'warn'"><t t-set="klass">warning</t></t>
|
||||
<t t-if="child.global_result == 'ok'"><t t-set="klass">success</t></t>
|
||||
<t t-if="child.global_result == 'killed'"><t t-set="klass">killed</t></t>
|
||||
<a t-attf-href='/runbot/build/{{child.id}}'><span t-attf-class="label label-{{klass}}"><t t-esc="child.config_data.get('db_name') or child.config_id.name"/></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="runbot.monitoring">
|
||||
<t t-call="runbot.frontend_no_nav">
|
||||
<t t-set="head">
|
||||
|
Loading…
Reference in New Issue
Block a user