mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[IMP] runbot: Improve stats listing display
Sort trigger and group them by category, better selection of categories to display on stats page
This commit is contained in:
parent
9660cf6517
commit
3e570eb8d1
@ -251,4 +251,3 @@ class ReProxy():
|
||||
|
||||
VERBOSE = re.VERBOSE
|
||||
MULTILINE = re.MULTILINE
|
||||
|
||||
|
@ -553,7 +553,7 @@ class Runbot(Controller):
|
||||
|
||||
|
||||
@route(['/runbot/stats/'], type='json', auth="public", website=False, sitemap=False)
|
||||
def stats_json(self, bundle_id=False, trigger_id=False, key_category='', center_build_id=False, limit=100, search=None, **post):
|
||||
def stats_json(self, bundle_id=False, trigger_id=False, key_category='', center_build_id=False, ok_only=False, limit=100, search=None, **post):
|
||||
""" Json stats """
|
||||
trigger_id = trigger_id and int(trigger_id)
|
||||
bundle_id = bundle_id and int(bundle_id)
|
||||
@ -570,6 +570,8 @@ class Runbot(Controller):
|
||||
('slot_ids.batch_id.bundle_id', '=', bundle_id),
|
||||
('params_id.trigger_id', '=', trigger.id),
|
||||
]
|
||||
if ok_only:
|
||||
builds_domain += ('global_result', '=', 'ok')
|
||||
builds = request.env['runbot.build'].with_context(active_test=False)
|
||||
if center_build_id:
|
||||
builds = builds.search(
|
||||
@ -585,7 +587,7 @@ class Runbot(Controller):
|
||||
builds = builds.search([('id', 'child_of', builds.ids)])
|
||||
|
||||
parents = {b.id: b.top_parent.id for b in builds.with_context(prefetch_fields=False)}
|
||||
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
|
||||
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():
|
||||
if values:
|
||||
@ -596,8 +598,21 @@ class Runbot(Controller):
|
||||
@route(['/runbot/stats/<model("runbot.bundle"):bundle>/<model("runbot.trigger"):trigger>'], type='http', auth="public", website=True, sitemap=False)
|
||||
def modules_stats(self, bundle, trigger, search=None, **post):
|
||||
"""Modules statistics"""
|
||||
categories = set()
|
||||
|
||||
categories = request.env['runbot.build.stat.regex'].search([]).mapped('name')
|
||||
def list_config_categories(config):
|
||||
nonlocal categories
|
||||
for config_step in config.step_ids:
|
||||
regex_ids = config_step.build_stat_regex_ids
|
||||
if not regex_ids:
|
||||
regex_ids = regex_ids.search([('generic', '=', True)])
|
||||
categories |= set(regex_ids.mapped('name'))
|
||||
for config in config_step.create_config_ids:
|
||||
list_config_categories(config)
|
||||
|
||||
list_config_categories(trigger.config_id)
|
||||
|
||||
categories = sorted(categories)
|
||||
|
||||
context = {
|
||||
'stats_categories': categories,
|
||||
|
@ -65,7 +65,7 @@
|
||||
<span t-esc="user_id.name[:23] + '...' if user_id.name and len(user_id.name) > 25 else user_id.name"/>
|
||||
</b>
|
||||
</a>
|
||||
<div class="dropdown-menu js_usermenu" role="menu">
|
||||
<div class="dropdown-menu dropdown-menu-end js_usermenu" role="menu">
|
||||
<a class="dropdown-item" id="o_logout" role="menuitem" t-attf-href="/web/session/logout?redirect=/">Logout</a>
|
||||
<a class="dropdown-item" role="menuitem" t-attf-href="/web">Web</a>
|
||||
<div t-if="user_id.runbot_team_ids" class="dropdown-divider"/>
|
||||
@ -380,11 +380,17 @@
|
||||
<i t-attf-class="fa fa-bar-chart"/>
|
||||
<span class="caret"/>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-end" role="menu">
|
||||
<t t-foreach="project.trigger_ids" t-as="trigger">
|
||||
<a class="dropdown-item" t-if="trigger.has_stats" t-attf-href="/runbot/stats/{{bundle.id}}/{{trigger.id}}">
|
||||
<t t-esc="trigger.name" />
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-start" role="menu">
|
||||
<t t-foreach="project.trigger_ids.sorted(lambda t: (t.category_id.id, t.sequence, t.id))" t-as="trigger">
|
||||
<t t-if="trigger.has_stats and not trigger.manual" >
|
||||
<t t-if="current_category != trigger.category_id">
|
||||
<span class="dropdown-item"><b><t t-esc="trigger.category_id.name"/></b></span>
|
||||
<t t-set="current_category" t-value="trigger.category_id"/>
|
||||
</t>
|
||||
<a class="dropdown-item" t-attf-href="/runbot/stats/{{bundle.id}}/{{trigger.id}}">
|
||||
<t t-esc="trigger.name" />
|
||||
</a>
|
||||
</t>
|
||||
</t>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -12,6 +12,7 @@
|
||||
<field name="generic"/>
|
||||
<field name="description"/>
|
||||
<field name="sequence"/>
|
||||
<field name="config_step_ids"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user