[FIX] runbot: get_ref_time as float

get_ref_time was cast from float to datetime and thus,
milliseconds where lost. Storing it as float make code
easier to read and avoid this rounding that was breaking
 this feature.
This commit is contained in:
Xavier-Do 2019-06-24 15:56:06 +02:00
parent b64c7adce2
commit 94a680f0c8
2 changed files with 4 additions and 4 deletions

View File

@ -6,7 +6,7 @@
'author': "Odoo SA",
'website': "http://runbot.odoo.com",
'category': 'Website',
'version': '4.0',
'version': '4.1',
'depends': ['website', 'base'],
'data': [
'security/runbot_security.xml',

View File

@ -36,7 +36,7 @@ class runbot_repo(models.Model):
default='poll',
string="Mode", required=True, help="hook: Wait for webhook on /runbot/hook/<id> i.e. github push event")
hook_time = fields.Datetime('Last hook time')
get_ref_time = fields.Datetime('Last refs db update')
get_ref_time = fields.Float('Last refs db update')
duplicate_id = fields.Many2one('runbot.repo', 'Duplicate repo', help='Repository for finding duplicate builds')
modules = fields.Char("Modules to install", help="Comma-separated list of modules to install and test.")
modules_auto = fields.Selection([('none', 'None (only explicit modules list)'),
@ -171,8 +171,8 @@ class runbot_repo(models.Model):
self.ensure_one()
get_ref_time = self._get_fetch_head_time()
if not self.get_ref_time or get_ref_time > dt2time(self.get_ref_time):
self.get_ref_time = datetime.datetime.fromtimestamp(get_ref_time).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
if not self.get_ref_time or get_ref_time > self.get_ref_time:
self.get_ref_time = get_ref_time
fields = ['refname', 'objectname', 'committerdate:iso8601', 'authorname', 'authoremail', 'subject', 'committername', 'committeremail']
fmt = "%00".join(["%(" + field + ")" for field in fields])
git_refs = self._git(['for-each-ref', '--format', fmt, '--sort=-committerdate', 'refs/heads', 'refs/pull'])