summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-12-15 20:21:04 +0100
committerDan McGee <dan@archlinux.org>2013-12-15 20:21:04 +0100
commit3c7b02753a4f742eeb66b8deea2fc3f179b87b8e (patch)
treeba5b1cb647d1a90df841411617689567a0345819
parenta38665c65272a22a474a85d3af47d64293c8844e (diff)
downloadarchweb-3c7b02753a4f742eeb66b8deea2fc3f179b87b8e.tar.gz
archweb-3c7b02753a4f742eeb66b8deea2fc3f179b87b8e.tar.xz
Add delay function to MirrorLog model
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--mirrors/models.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/mirrors/models.py b/mirrors/models.py
index 47e2051..d2c64c5 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)