From 9fb7e94de9f0d2b24b427cf83696250841caea6f Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Mon, 25 Jul 2022 11:54:26 +0200 Subject: [PATCH] [IMP] add load info page --- runbot/controllers/frontend.py | 23 +++++++++++++- runbot/models/build_stat_regex.py | 2 ++ runbot/static/src/css/runbot.css | 5 ++- runbot/templates/dashboard.xml | 53 +++++++++++++++++++++++++++++++ runbot/templates/utils.xml | 40 ++++++++++++----------- runbot/views/stat_views.xml | 2 ++ 6 files changed, 104 insertions(+), 21 deletions(-) diff --git a/runbot/controllers/frontend.py b/runbot/controllers/frontend.py index 16c46919..eb98be03 100644 --- a/runbot/controllers/frontend.py +++ b/runbot/controllers/frontend.py @@ -508,7 +508,8 @@ class Runbot(Controller): 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(): - res.setdefault(parents[build_id], {}).update(values) + if values: + res.setdefault(parents[build_id], {}).update(values) # we need to update here to manage the post install case: we want to combine stats from all post_install childrens. return res @@ -525,3 +526,23 @@ class Runbot(Controller): } return request.render("runbot.modules_stats", context) + + @route(['/runbot/load_info'], type='http', auth="user", website=True, sitemap=False) + def load_infos(self, **post): + build_by_bundle = {} + + for build in request.env['runbot.build'].search([('local_state', 'in', ('pending', 'testing'))], order='id'): + build_by_bundle.setdefault(build.params_id.create_batch_id.bundle_id, []).append(build) + + build_by_bundle = list(build_by_bundle.items()) + build_by_bundle.sort(key=lambda x: -len(x[1])) + pending_count, level, scheduled_count = self._pending() + context = { + 'build_by_bundle': build_by_bundle, + 'pending_total': pending_count, + 'pending_level': level, + 'scheduled_count': scheduled_count, + 'hosts_data': request.env['runbot.host'].search([('assigned_only', '=', False)]), + } + + return request.render("runbot.load_info", context) diff --git a/runbot/models/build_stat_regex.py b/runbot/models/build_stat_regex.py index edec91a0..8e5eb9fc 100644 --- a/runbot/models/build_stat_regex.py +++ b/runbot/models/build_stat_regex.py @@ -24,12 +24,14 @@ class BuildStatRegex(models.Model): _name = "runbot.build.stat.regex" _description = "Statistics regex" + _order = 'sequence,id' name = fields.Char("Key Name") regex = fields.Char("Regular Expression") description = fields.Char("Description") generic = fields.Boolean('Generic', help='Executed when no regex on the step', default=True) config_step_ids = fields.Many2many('runbot.build.config.step', string='Config Steps') + sequence = fields.Integer('Sequence') @api.constrains("name", "regex") def _check_regex(self): diff --git a/runbot/static/src/css/runbot.css b/runbot/static/src/css/runbot.css index 31ba779b..c19974ee 100644 --- a/runbot/static/src/css/runbot.css +++ b/runbot/static/src/css/runbot.css @@ -27,7 +27,10 @@ a { a:hover { color: #005452; - text-decoration: underline; +} + +a.slots_infos:hover { + text-decoration: none; } diff --git a/runbot/templates/dashboard.xml b/runbot/templates/dashboard.xml index 96f80c1f..d96cdea9 100644 --- a/runbot/templates/dashboard.xml +++ b/runbot/templates/dashboard.xml @@ -226,5 +226,58 @@ + diff --git a/runbot/templates/utils.xml b/runbot/templates/utils.xml index 96105dd0..6d168eff 100644 --- a/runbot/templates/utils.xml +++ b/runbot/templates/utils.xml @@ -152,25 +152,27 @@