From 0d2219398b5225a03463cc7b1f7cb7adf5290470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 3 Nov 2014 15:21:04 +0100 Subject: [PATCH] determine wants_frequent_checks based on last update, not current time (#5851) --- hobo/environment/models.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hobo/environment/models.py b/hobo/environment/models.py index edecd4c..c75718b 100644 --- a/hobo/environment/models.py +++ b/hobo/environment/models.py @@ -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()