[FIX] runbot: guess_result conversion to record api

This commit is contained in:
Julien Legros 2018-03-16 10:10:18 +01:00
parent 297d502afd
commit 278d4ed449
No known key found for this signature in database
GPG Key ID: 05AABD5397BF114D

View File

@ -219,7 +219,8 @@ class runbot_build(models.Model):
build.domain = "%s:%s" % (domain, build.port)
def _guess_result(self):
self.env.cr.execute("""
cr = self.env.cr
cr.execute("""
SELECT b.id,
CASE WHEN b.state != 'testing' THEN b.result
WHEN array_agg(l.level)::text[] && ARRAY['ERROR', 'CRITICAL'] THEN 'ko'
@ -231,7 +232,9 @@ class runbot_build(models.Model):
WHERE b.id IN %s
GROUP BY b.id
""", [tuple(self.ids)])
return dict(self.env.cr.fetchall())
result = {row[0]: row[1] for row in cr.fetchall()}
for build in self:
build.guess_result = result[build.id]
def _get_time(self):
"""Return the time taken by the tests"""