From 622b5d915530b547572a16a85af761de16cd2c4a Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 8 Dec 2015 10:33:01 +0100 Subject: [PATCH 1/2] [FIX] only work on branches with builds fixes #83 --- runbot/runbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runbot/runbot.py b/runbot/runbot.py index 4b4c2596..e12e753a 100644 --- a/runbot/runbot.py +++ b/runbot/runbot.py @@ -1174,7 +1174,7 @@ def repo(self, repo=None, search='', limit='100', refresh='', **post): domain += ['|', '|', ('dest', 'ilike', search), ('subject', 'ilike', search), ('branch_id.branch_name', 'ilike', search)] build_ids = build_obj.search(cr, uid, domain, limit=int(limit)) - branch_ids, build_by_branch_ids = [], {} + build_by_branch_ids = {} if build_ids: branch_query = """ @@ -1214,7 +1214,7 @@ def repo(self, repo=None, search='', limit='100', refresh='', **post): rec[0]: [r for r in rec[1:] if r is not None] for rec in cr.fetchall() } - branches = branch_obj.browse(cr, uid, branch_ids, context=request.context) + branches = branch_obj.browse(cr, uid, build_by_branch_ids.keys(), context=request.context) build_ids = flatten(build_by_branch_ids.values()) build_dict = {build.id: build for build in build_obj.browse(cr, uid, build_ids, context=request.context) } From 4a6125dc434f2db2e504f67d11f8bee4268fca6d Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 8 Dec 2015 16:41:19 +0100 Subject: [PATCH 2/2] [IMP] sort sticky branches first --- runbot/runbot.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runbot/runbot.py b/runbot/runbot.py index e12e753a..61acb203 100644 --- a/runbot/runbot.py +++ b/runbot/runbot.py @@ -1225,7 +1225,13 @@ def branch_info(branch): } context.update({ - 'branches': [branch_info(b) for b in branches], + 'branches': [ + branch_info(b) for b in + sorted( + branches, + lambda x, y: cmp(x.name, y.name) + if x.sticky == y.sticky else -1 if x.sticky else 1) + ], 'testing': count([('repo_id','=',repo.id), ('state','=','testing')]), 'running': count([('repo_id','=',repo.id), ('state','=','running')]), 'pending': count([('repo_id','=',repo.id), ('state','=','pending')]),