From 011d5245ae310966f129d0fa4ef8338b09ec2fbc Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Fri, 5 Jan 2024 16:59:47 +0100 Subject: [PATCH] [IMP] runbot: improve reflogs list on branch page Sort the reflogs in reverse and adds a pager. --- runbot/controllers/frontend.py | 15 +++++++++++++-- runbot/templates/branch.xml | 17 +++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/runbot/controllers/frontend.py b/runbot/controllers/frontend.py index f8fa6567..db3f37da 100644 --- a/runbot/controllers/frontend.py +++ b/runbot/controllers/frontend.py @@ -352,16 +352,27 @@ class Runbot(Controller): @route([ '/runbot/branch/', + '/runbot/branch//page/' ], website=True, auth='public', type='http', sitemap=False) - def branch(self, branch=None, **kwargs): + def branch(self, branch=None, page=1, limit=30, **kwargs): pr_branch = branch.bundle_id.branch_ids.filtered(lambda rec: not rec.is_pr and rec.id != branch.id and rec.remote_id.repo_id == branch.remote_id.repo_id)[:1] branch_pr = branch.bundle_id.branch_ids.filtered(lambda rec: rec.is_pr and rec.id != branch.id and rec.remote_id.repo_id == branch.remote_id.repo_id)[:1] + reflog_count = len(branch.reflog_ids) + pager = request.website.pager( + url=f'/runbot/branch/{branch.id}', + total=reflog_count, + page=page, + step=30, + ) + reflog_ids = branch.reflog_ids.sorted(reverse=True)[pager.get('offset', 0):pager.get('offset', 0) + limit] context = { 'branch': branch, 'project': branch.remote_id.repo_id.project_id, 'title': 'Branch %s' % branch.name, 'pr_branch': pr_branch, - 'branch_pr': branch_pr + 'branch_pr': branch_pr, + 'reflog_ids': reflog_ids, + 'pager': pager, } return request.render('runbot.branch', context) diff --git a/runbot/templates/branch.xml b/runbot/templates/branch.xml index 34f32fc1..14e8f649 100644 --- a/runbot/templates/branch.xml +++ b/runbot/templates/branch.xml @@ -27,13 +27,7 @@ Bundle: - - - + @@ -57,6 +51,9 @@ + + + @@ -67,10 +64,10 @@ - - + -
Subject
+
+