From 864ba5104ea5d0ed3960fe0d3d864043eb51e1ec Mon Sep 17 00:00:00 2001 From: Matt Prahl Date: Wed, 17 Aug 2016 10:30:01 -0400 Subject: [PATCH] Modify the database timestamps when the build state changes --- rida/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rida/models.py b/rida/models.py index c296e205..847339a0 100644 --- a/rida/models.py +++ b/rida/models.py @@ -138,8 +138,7 @@ class ModuleBuild(RidaBase): modulemd=modulemd, scmurl=scmurl, owner=username, - time_submitted=now, - time_modified=now + time_submitted=now ) session.add(module) session.commit() @@ -153,8 +152,14 @@ class ModuleBuild(RidaBase): def transition(self, conf, state): """ Record that a build has transitioned state. """ + now = datetime.utcnow() old_state = self.state self.state = state + self.time_modified = now + + if self.state in ['done', 'failed']: + self.time_completed = now + log.debug("%r, state %r->%r" % (self, old_state, self.state)) rida.messaging.publish( modname='rida',