From 3c7b02753a4f742eeb66b8deea2fc3f179b87b8e Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 15 Dec 2013 13:21:04 -0600 Subject: Add delay function to MirrorLog model Signed-off-by: Dan McGee --- mirrors/models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mirrors/models.py b/mirrors/models.py index 47e2051b..d2c64c51 100644 --- a/mirrors/models.py +++ b/mirrors/models.py @@ -1,3 +1,4 @@ +from datetime import timedelta import socket from urlparse import urlparse @@ -159,6 +160,12 @@ class MirrorLog(models.Model): is_success = models.BooleanField(default=True) error = models.TextField(blank=True, default='') + def delay(self): + # sanity check, this shouldn't happen + if self.check_time < self.last_sync: + return timedelta() + return self.check_time - self.last_sync + def __unicode__(self): return "Check of %s at %s" % (self.url.url, self.check_time) -- cgit v1.2.3-54-g00ecf