From 9c7cee657d156e9346d142538dbb993cd686a550 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Thu, 12 Nov 2020 16:08:25 +0100 Subject: [PATCH] [IMP] runbot: improve build error frontend page On the build error web page, a regular assigned error is not shown to all users. With this commit, a regular build error (not only random) will be shown if the error is assigned. --- runbot/controllers/frontend.py | 36 ++++++++++---- runbot/models/build_error.py | 16 +++---- runbot/templates/build_error.xml | 80 +++++++++++++++++++++++++++++++- 3 files changed, 115 insertions(+), 17 deletions(-) diff --git a/runbot/controllers/frontend.py b/runbot/controllers/frontend.py index 8d01e356..7e168239 100644 --- a/runbot/controllers/frontend.py +++ b/runbot/controllers/frontend.py @@ -351,16 +351,36 @@ class Runbot(Controller): return request.render(view_id if view_id else "runbot.monitoring", qctx) @route(['/runbot/errors', - '/runbot/errors/'], type='http', auth='user', website=True) - def build_errors(self, error_id=None, **kwargs): - build_errors = request.env['runbot.build.error'].search([('random', '=', True), ('parent_id', '=', False), ('responsible', '!=', request.env.user.id)]).filtered(lambda rec: len(rec.children_build_ids) > 1) - assigned_errors = request.env['runbot.build.error'].search([('responsible', '=', request.env.user.id)]) - build_errors = build_errors.sorted(lambda rec: (rec.last_seen_date.date(), rec.build_count), reverse=True) - assigned_errors = assigned_errors.sorted(lambda rec: (rec.last_seen_date.date(), rec.build_count), reverse=True) - build_errors = assigned_errors + build_errors + '/runbot/errors/page/'], type='http', auth='user', website=True) + def build_errors(self, error_id=None, sort=None, page=1, limit=20, **kwargs): + sort_order_choices = { + 'last_seen_date desc': 'Last seen date: Newer First', + 'last_seen_date asc': 'Last seen date: Older First', + 'build_count desc': 'Number seen: High to Low', + 'build_count asc': 'Number seen: Low to High', + 'responsible asc': 'Assignee: A - Z', + 'responsible desc': 'Assignee: Z - A', + 'module_name asc': 'Module name: A - Z', + 'module_name desc': 'Module name: Z -A' + } + + sort_order = sort if sort in sort_order_choices else 'last_seen_date desc' + + current_user_errors = request.env['runbot.build.error'].search([('responsible', '=', request.env.user.id)], order='last_seen_date desc, build_count desc') + + domain = [('responsible', '!=', request.env.user.id), ('build_count', '>', 1)] + build_errors_count = request.env['runbot.build.error'].search_count(domain) + url_args = {} + url_args['sort'] = sort + pager = request.website.pager(url='/runbot/errors/', url_args=url_args, total=build_errors_count, page=page, step=limit) + + build_errors = request.env['runbot.build.error'].search(domain, order=sort_order, limit=limit, offset=pager.get('offset', 0)) qctx = { + 'current_user_errors': current_user_errors, 'build_errors': build_errors, - 'title': 'Build Errors' + 'title': 'Build Errors', + 'sort_order_choices': sort_order_choices, + 'pager': pager } return request.render('runbot.build_error', qctx) diff --git a/runbot/models/build_error.py b/runbot/models/build_error.py index 62f652de..0a005d74 100644 --- a/runbot/models/build_error.py +++ b/runbot/models/build_error.py @@ -32,15 +32,15 @@ class BuildError(models.Model): trigger_ids = fields.Many2many('runbot.trigger', compute='_compute_trigger_ids') active = fields.Boolean('Error is not fixed', default=True, tracking=True) tag_ids = fields.Many2many('runbot.build.error.tag', string='Tags') - build_count = fields.Integer(compute='_compute_build_counts', string='Nb seen') + build_count = fields.Integer(compute='_compute_build_counts', string='Nb seen', store=True) parent_id = fields.Many2one('runbot.build.error', 'Linked to', index=True) child_ids = fields.One2many('runbot.build.error', 'parent_id', string='Child Errors', context={'active_test': False}) children_build_ids = fields.Many2many('runbot.build', compute='_compute_children_build_ids', string='Children builds') error_history_ids = fields.Many2many('runbot.build.error', compute='_compute_error_history_ids', string='Old errors', context={'active_test': False}) first_seen_build_id = fields.Many2one('runbot.build', compute='_compute_first_seen_build_id', string='First Seen build') first_seen_date = fields.Datetime(string='First Seen Date', related='first_seen_build_id.create_date') - last_seen_build_id = fields.Many2one('runbot.build', compute='_compute_last_seen_build_id', string='Last Seen build') - last_seen_date = fields.Datetime(string='Last Seen Date', related='last_seen_build_id.create_date') + last_seen_build_id = fields.Many2one('runbot.build', compute='_compute_last_seen_build_id', string='Last Seen build', store=True) + last_seen_date = fields.Datetime(string='Last Seen Date', related='last_seen_build_id.create_date', store=True) test_tags = fields.Char(string='Test tags', help="Comma separated list of test_tags to use to reproduce/remove this error") @api.constrains('test_tags') @@ -65,10 +65,10 @@ class BuildError(models.Model): (build_error.child_ids - self).write({'active': vals['active']}) return super(BuildError, self).write(vals) - @api.depends('build_ids') + @api.depends('build_ids', 'child_ids.build_ids') def _compute_build_counts(self): for build_error in self: - build_error.build_count = len(build_error.children_build_ids) + build_error.build_count = len(build_error.build_ids | build_error.mapped('child_ids.build_ids')) @api.depends('build_ids') def _compute_bundle_ids(self): @@ -86,18 +86,18 @@ class BuildError(models.Model): for build_error in self: build_error.summary = build_error.content[:50] - @api.depends('child_ids') + @api.depends('build_ids', 'child_ids.build_ids') def _compute_children_build_ids(self): for build_error in self: all_builds = build_error.build_ids | build_error.mapped('child_ids.build_ids') build_error.children_build_ids = all_builds.sorted(key=lambda rec: rec.id, reverse=True) - @api.depends('build_ids', 'child_ids') + @api.depends('children_build_ids') def _compute_last_seen_build_id(self): for build_error in self: build_error.last_seen_build_id = build_error.children_build_ids and build_error.children_build_ids[0] or False - @api.depends('build_ids', 'child_ids') + @api.depends('children_build_ids') def _compute_first_seen_build_id(self): for build_error in self: build_error.first_seen_build_id = build_error.children_build_ids and build_error.children_build_ids[-1] or False diff --git a/runbot/templates/build_error.xml b/runbot/templates/build_error.xml index faf4b870..26709f61 100644 --- a/runbot/templates/build_error.xml +++ b/runbot/templates/build_error.xml @@ -6,7 +6,81 @@
-

Current Random Bugs on Runbot Builds

+ +

Your assigned bugs Bugs on Runbot Builds

+
+
+
+
+
Last seen date
+
Module
+
Summary
+
Nb Seen
+
Random
+
Assigned to
+
 
+
+
+
+ +
+
+
+
+
+
+ + +
+
+ +
+
+ +
+
+
+ + + + +
+
+
+ +
+
+
+                            
+                          
+
+
+
+
+
+
+ +

Current Bugs on Runbot Builds

+
+ +
+
@@ -15,6 +89,7 @@
Module
Summary
Nb Seen
+
Random
Assigned to
 
@@ -36,6 +111,9 @@
+
+ +