mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[ADD] runbot: sticky-dashboard page
This commit is contained in:
parent
9ebc8d6447
commit
aeada94df9
@ -1188,6 +1188,59 @@ class RunbotController(http.Controller):
|
|||||||
|
|
||||||
return request.render("runbot.repo", context)
|
return request.render("runbot.repo", context)
|
||||||
|
|
||||||
|
@http.route(['/runbot/sticky-dashboard'], type='http', auth="public", website=True)
|
||||||
|
def sticky_dashboard(self, refresh=None):
|
||||||
|
cr = request.cr
|
||||||
|
RB = request.env['runbot.build']
|
||||||
|
repos = request.env['runbot.repo'].search([]) # respect record rules
|
||||||
|
|
||||||
|
cr.execute("""SELECT bu.id
|
||||||
|
FROM runbot_branch br
|
||||||
|
JOIN LATERAL (SELECT *
|
||||||
|
FROM runbot_build bu
|
||||||
|
WHERE bu.branch_id = br.id
|
||||||
|
ORDER BY id DESC
|
||||||
|
LIMIT 3
|
||||||
|
) bu ON (true)
|
||||||
|
WHERE br.sticky
|
||||||
|
AND br.repo_id in %s
|
||||||
|
ORDER BY br.repo_id, br.branch_name, bu.id DESC
|
||||||
|
""", [tuple(repos._ids)])
|
||||||
|
|
||||||
|
builds = RB.browse(map(operator.itemgetter(0), cr.fetchall()))
|
||||||
|
|
||||||
|
count = RB.search_count
|
||||||
|
qctx = {
|
||||||
|
'refresh': refresh,
|
||||||
|
'host_stats': [],
|
||||||
|
'pending_total': count([('state', '=', 'pending')]),
|
||||||
|
}
|
||||||
|
|
||||||
|
repos_values = qctx['repo_dict'] = OrderedDict()
|
||||||
|
for build in builds:
|
||||||
|
repo = build.repo_id
|
||||||
|
branch = build.branch_id
|
||||||
|
r = repos_values.setdefault(repo.id, {'branches': OrderedDict()})
|
||||||
|
if 'name' not in r:
|
||||||
|
r.update({
|
||||||
|
'name': repo.name,
|
||||||
|
'testing': count([('repo_id', '=', repo.id), ('state', '=', 'testing')]),
|
||||||
|
'running': count([('repo_id', '=', repo.id), ('state', '=', 'running')]),
|
||||||
|
'pending': count([('repo_id', '=', repo.id), ('state', '=', 'pending')]),
|
||||||
|
})
|
||||||
|
b = r['branches'].setdefault(branch.id, {'name': branch.branch_name, 'builds': list()})
|
||||||
|
b['builds'].append(self.build_info(build))
|
||||||
|
|
||||||
|
for result in RB.read_group([], ['host'], ['host']):
|
||||||
|
if result['host']:
|
||||||
|
qctx['host_stats'].append({
|
||||||
|
'host': result['host'],
|
||||||
|
'testing': count([('state', '=', 'testing'), ('host', '=', result['host'])]),
|
||||||
|
'running': count([('state', '=', 'running'), ('host', '=', result['host'])]),
|
||||||
|
})
|
||||||
|
|
||||||
|
return request.render("runbot.sticky-dashboard", qctx)
|
||||||
|
|
||||||
def build_info(self, build):
|
def build_info(self, build):
|
||||||
real_build = build.duplicate_id if build.state == 'duplicate' else build
|
real_build = build.duplicate_id if build.state == 'duplicate' else build
|
||||||
return {
|
return {
|
||||||
|
@ -435,6 +435,79 @@
|
|||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
</template>
|
</template>
|
||||||
|
<template id="runbot.sticky-dashboard">
|
||||||
|
<t t-call='website.layout'>
|
||||||
|
<t t-set="head">
|
||||||
|
<t t-if="refresh">
|
||||||
|
<meta http-equiv="refresh" t-att-content="refresh"/>
|
||||||
|
</t>
|
||||||
|
<style>
|
||||||
|
.bg-killed {
|
||||||
|
background-color: #aaa;
|
||||||
|
}
|
||||||
|
h4 {
|
||||||
|
padding: 3px 0;
|
||||||
|
border-bottom: 1px solid grey;
|
||||||
|
}
|
||||||
|
.r-mb02 { margin-bottom: 0.2em; }
|
||||||
|
</style>
|
||||||
|
</t>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class='col-md-12'>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<p class="text-center">
|
||||||
|
<t t-foreach="host_stats" t-as="hs">
|
||||||
|
<span class="label label-default">
|
||||||
|
<t t-esc="hs['host']"/>: <t t-esc="hs['testing']"/> testing, <t t-esc="hs['running']"/> running
|
||||||
|
</span>&nbsp;
|
||||||
|
</t>
|
||||||
|
<span class="label label-info">Pending: <t t-esc="pending_total"/></span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<t t-foreach="repo_dict.values()" t-as="repo">
|
||||||
|
<h4><span><t t-esc="repo['name']"/></span>
|
||||||
|
<small class="pull-right">
|
||||||
|
<t t-esc="repo['testing']"/> testing,
|
||||||
|
<t t-esc="repo['running']"/> running,
|
||||||
|
<t t-esc="repo['pending']"/> pending.
|
||||||
|
</small></h4>
|
||||||
|
<div t-foreach="repo['branches'].values()" t-as="br">
|
||||||
|
<div class="col-md-2">
|
||||||
|
<i class="fa fa-star" style="color: #f0ad4e" />
|
||||||
|
<b t-esc="br['name']"/>
|
||||||
|
<small><t t-esc="br['builds'][0]['job_age']"/></small><br/>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-10 r-mb02">
|
||||||
|
<t t-foreach="br['builds']" t-as="bu">
|
||||||
|
<t t-if="bu['state']=='pending'"><t t-set="klass">default</t></t>
|
||||||
|
<t t-if="bu['state']=='testing'"><t t-set="klass">info</t></t>
|
||||||
|
<t t-if="bu['state'] in ['running','done'] and bu['result'] == 'ko'"><t t-set="klass">danger</t></t>
|
||||||
|
<t t-if="bu['state'] in ['running','done'] and bu['result'] == 'warn'"><t t-set="klass">warning</t></t>
|
||||||
|
<t t-if="bu['state'] in ['running','done'] and bu['result'] == 'ok'"><t t-set="klass">success</t></t>
|
||||||
|
<t t-if="bu['state'] in ['running','done'] and bu['result'] == 'skipped'"><t t-set="klass">default</t></t>
|
||||||
|
<t t-if="bu['state'] in ['running','done'] and bu['result'] == 'killed'"><t t-set="klass">killed</t></t>
|
||||||
|
<div t-attf-class="bg-{{klass}} col-md-4">
|
||||||
|
<i class="fa fa-at"></i>
|
||||||
|
<t t-esc="bu['author']"/>
|
||||||
|
<t t-if="bu['committer'] and bu['author'] != bu['committer']" t-id="bu['committer']">
|
||||||
|
(<i class="fa fa-sign-out"></i>&nbsp;<t t-esc="bu['committer']"/>)
|
||||||
|
</t>
|
||||||
|
<br/>
|
||||||
|
<i class="fa fa-envelope-o"></i>
|
||||||
|
<span t-esc="bu['subject'][:32] + ('...' if bu['subject'][32:] else '') " t-att-title="bu['subject']"/>
|
||||||
|
<br/>
|
||||||
|
<t t-call="runbot.build_name"/> — <small><t t-esc="bu['dest']"/> on <t t-esc="bu['host']"/></small>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template id="runbot.build">
|
<template id="runbot.build">
|
||||||
<t t-call='website.layout'>
|
<t t-call='website.layout'>
|
||||||
|
Loading…
Reference in New Issue
Block a user