Check if archives are empty before getting them
This commit is contained in:
parent
c7da5c26c8
commit
9e49079ef1
|
@ -12,16 +12,22 @@ class Repo(models.Model):
|
||||||
label = models.OneToOneField(Label, on_delete=models.CASCADE, unique=True)
|
label = models.OneToOneField(Label, on_delete=models.CASCADE, unique=True)
|
||||||
|
|
||||||
def last_backup(self):
|
def last_backup(self):
|
||||||
latest = self.latest_archive().start.replace(tzinfo=None)
|
if self.archives.all().exists():
|
||||||
seconds_since = int((datetime.utcnow() - latest).total_seconds())
|
latest = self.latest_archive().start.replace(tzinfo=None)
|
||||||
return f"{seconds_to_string(seconds_since, False, True)} ago"
|
seconds_since = int((datetime.utcnow() - latest).total_seconds())
|
||||||
|
return f"{seconds_to_string(seconds_since, False, True)} ago"
|
||||||
|
else:
|
||||||
|
return "No archives stored"
|
||||||
|
|
||||||
def latest_archive(self):
|
def latest_archive(self):
|
||||||
return self.archives.order_by('-start')[0]
|
return self.archives.order_by('-start')[0]
|
||||||
|
|
||||||
def size(self):
|
def size(self):
|
||||||
cache = self.latest_archive().cache
|
if self.archives.all().exists():
|
||||||
return f"{bytes_to_string(cache.unique_csize)}"
|
cache = self.latest_archive().cache
|
||||||
|
return f"{bytes_to_string(cache.unique_csize)}"
|
||||||
|
else:
|
||||||
|
return "No archives stored"
|
||||||
|
|
||||||
def recent_errors(self):
|
def recent_errors(self):
|
||||||
days = 7
|
days = 7
|
||||||
|
|
Loading…
Reference in New Issue
Block a user