From c85735870a55f170954cf41c84bcb2135a089377 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 29 Jul 2022 14:25:11 +0200 Subject: [PATCH] [FIX] runbot_merge: bugs in log of branch stagings (in frontend) - Some batches in a few stagings are apparently empty (e.g. batch 71771 from staging 32511), the listing was not resilient to such issues. Update the code to suppress the display of empty batches. - The possibility of accessing `/runbot_merge/` with a non-existent branch had not been considered and triggered a rendering error in the template. Fixes #630, fixes #631 --- runbot_merge/controllers/dashboard.py | 8 ++++++-- runbot_merge/views/templates.xml | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/runbot_merge/controllers/dashboard.py b/runbot_merge/controllers/dashboard.py index dfaf0670..e80a2f15 100644 --- a/runbot_merge/controllers/dashboard.py +++ b/runbot_merge/controllers/dashboard.py @@ -19,13 +19,17 @@ class MergebotDashboard(Controller): @route('/runbot_merge/', auth='public', type='http', website=True) def stagings(self, branch_id, until=None): + branch = request.env['runbot_merge.branch'].browse(branch_id).sudo().exists() + if not branch: + raise werkzeug.exceptions.NotFound() + stagings = request.env['runbot_merge.stagings'].with_context(active_test=False).sudo().search([ - ('target', '=', branch_id), + ('target', '=', branch.id), ('staged_at', '<=', until) if until else (True, '=', True), ], order='staged_at desc', limit=LIMIT+1) return request.render('runbot_merge.branch_stagings', { - 'branch': request.env['runbot_merge.branch'].browse(branch_id).sudo(), + 'branch': branch, 'stagings': stagings[:LIMIT], 'next': stagings[-1].staged_at if len(stagings) > LIMIT else None, }) diff --git a/runbot_merge/views/templates.xml b/runbot_merge/views/templates.xml index 0e87428d..d99c4d42 100644 --- a/runbot_merge/views/templates.xml +++ b/runbot_merge/views/templates.xml @@ -248,8 +248,8 @@ -