From e51412d5589e8c018ddc1936209defe6c761ba62 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Mon, 24 Jun 2019 14:18:01 +0200 Subject: [PATCH] [IMP] runbot: only consider refs newer than max_age MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When getting new refs, a lot of them are really old and the find_new_commits is called for each one and thus browsing branches. With this commit, refs older than configured max_age are ignored. Co-authored-by: Xavier Dollé (xdo@odoo.com) --- runbot/models/repo.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runbot/models/repo.py b/runbot/models/repo.py index f090004a..139cc2ce 100644 --- a/runbot/models/repo.py +++ b/runbot/models/repo.py @@ -290,8 +290,10 @@ class runbot_repo(models.Model): for repo in self: try: ref = repo._get_refs() - if ref: - refs[repo] = ref + max_age = int(self.env['ir.config_parameter'].get_param('runbot.runbot_max_age', default=30)) + good_refs = [r for r in ref if dateutil.parser.parse(r[2][:19]) + datetime.timedelta(days=max_age) > datetime.datetime.now()] + if good_refs: + refs[repo] = good_refs except Exception: _logger.exception('Fail to get refs for repo %s', repo.name) if repo in refs: