From 3e570eb8d1f9417e14381686aff10196d62a9827 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Fri, 6 Sep 2024 09:25:24 +0200 Subject: [PATCH] [IMP] runbot: Improve stats listing display Sort trigger and group them by category, better selection of categories to display on stats page --- runbot/common.py | 1 - runbot/controllers/frontend.py | 21 ++++++++++++++++++--- runbot/templates/utils.xml | 18 ++++++++++++------ runbot/views/stat_views.xml | 1 + 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/runbot/common.py b/runbot/common.py index e774a193..7bc861f1 100644 --- a/runbot/common.py +++ b/runbot/common.py @@ -251,4 +251,3 @@ class ReProxy(): VERBOSE = re.VERBOSE MULTILINE = re.MULTILINE - diff --git a/runbot/controllers/frontend.py b/runbot/controllers/frontend.py index c7980c1d..2b176d85 100644 --- a/runbot/controllers/frontend.py +++ b/runbot/controllers/frontend.py @@ -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//'], 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, diff --git a/runbot/templates/utils.xml b/runbot/templates/utils.xml index eb9ad26f..33acd1aa 100644 --- a/runbot/templates/utils.xml +++ b/runbot/templates/utils.xml @@ -65,7 +65,7 @@ -