determine wants_frequent_checks based on last update, not current time (#5851)

This commit is contained in:
Frédéric Péters 2014-11-03 15:21:04 +01:00
parent a9d8481489
commit 0d2219398b
1 changed files with 9 additions and 1 deletions

View File

@ -72,10 +72,18 @@ class ServiceBase(models.Model):
self.save(update_fields=('last_operational_check_timestamp', 'last_operational_success_timestamp'))
def wants_frequent_checks(self):
# decides if a "being deployed..." spinner should be displayed (and
# automatically hidden) next to the service.
if self.last_operational_success_timestamp is not None:
# if the service has been marked as operational, we don't need a
# spinner at all.
return False
if self.last_operational_check_timestamp is None:
# if the service has never been checked, sure we wants a spinner.
return True
two_minutes = datetime.timedelta(minutes=2)
return (now() - self.last_operational_check_timestamp < two_minutes)
# monitor actively for two minutes max.
return (self.last_operational_check_timestamp - self.last_update_timestamp) < two_minutes
def as_dict(self):
as_dict = dict([(x, y) for (x, y) in self.__dict__.items()