From c24df5fac292ff45f14cc4be12e3188b91cb78a9 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Mon, 20 May 2019 13:51:58 +0200 Subject: [PATCH] [FIX] runbot: choose quickconnect build with same config When the quickconnect button is used, the last running build is searched in the last 10 builds. If no running build is found, the last one is rebuilt, even if it's a nightly build. With this commit, the quickconnect build is choosen only among the ones with the same config. --- runbot/controllers/frontend.py | 21 +++++++-------------- runbot/models/branch.py | 6 ------ runbot/templates/frontend.xml | 2 +- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/runbot/controllers/frontend.py b/runbot/controllers/frontend.py index 2653980c..d7c57838 100644 --- a/runbot/controllers/frontend.py +++ b/runbot/controllers/frontend.py @@ -178,27 +178,20 @@ class Runbot(Controller): } return request.render("runbot.build", context) - @route(['/runbot/b/', '/runbot//'], type='http', auth="public", website=True) - def fast_launch(self, branch_name=False, repo=False, **post): + @route(['/runbot/quick_connect/'], type='http', auth="public", website=True) + def fast_launch(self, branch, **post): """Connect to the running Odoo instance""" Build = request.env['runbot.build'] - - domain = [('branch_id.branch_name', '=', branch_name)] - - if repo: - domain.extend([('branch_id.repo_id', '=', repo.id)]) - order = "sequence desc" - else: - order = 'repo_id ASC, sequence DESC' + domain = [('branch_id', '=', branch.id), ('config_id', '=', branch.config_id.id)] # Take the 10 lasts builds to find at least 1 running... Else no luck - builds = Build.search(domain, order=order, limit=10) + builds = Build.search(domain, order='sequence desc', limit=10) if builds: last_build = False for build in builds: - if build.local_state == 'running' or (build.local_state == 'duplicate' and build.duplicate_id.local_state == 'running'): - last_build = build if build.local_state == 'running' else build.duplicate_id + if build.real_build.local_state == 'running': + last_build = build.real_build break if not last_build: @@ -208,7 +201,7 @@ class Runbot(Controller): if last_build.local_state != 'running': url = "/runbot/build/%s?ask_rebuild=1" % last_build.id else: - url = build.branch_id._get_branch_quickconnect_url(last_build.domain, last_build.dest)[build.branch_id.id] + url = "http://%s/web/login?db=%s-all&login=admin&redirect=/web?debug=1" % (last_build.domain, last_build.dest) else: return request.not_found() return werkzeug.utils.redirect(url) diff --git a/runbot/models/branch.py b/runbot/models/branch.py index d1769468..7d85b511 100644 --- a/runbot/models/branch.py +++ b/runbot/models/branch.py @@ -93,12 +93,6 @@ class runbot_branch(models.Model): return super(runbot_branch, self).create(vals) - def _get_branch_quickconnect_url(self, fqdn, dest): - self.ensure_one() - r = {} - r[self.id] = "http://%s/web/login?db=%s-all&login=admin&redirect=/web?debug=1" % (fqdn, dest) - return r - def _get_last_coverage_build(self): """ Return the last build with a coverage value > 0""" self.ensure_one() diff --git a/runbot/templates/frontend.xml b/runbot/templates/frontend.xml index 2a08fe0b..668e8d67 100644 --- a/runbot/templates/frontend.xml +++ b/runbot/templates/frontend.xml @@ -119,7 +119,7 @@