diff --git a/runbot/runbot.py b/runbot/runbot.py index 4b4c2596..61acb203 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) } @@ -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')]),