Show errors in last week
This commit is contained in:
parent
a4cae2ee2c
commit
5952578754
|
@ -74,9 +74,12 @@ class Repo(models.Model):
|
|||
size = self.size()
|
||||
return bytes_to_string(size)
|
||||
|
||||
def recent_errors(self, days: int = 7, limit: int = 3):
|
||||
def recent_errors(self, days: int = 7, limit: int = None):
|
||||
days_ago = (datetime.utcnow() - timedelta(days=days))
|
||||
errors = self.label.errors.all().filter(time__gt=days_ago)
|
||||
if limit is None:
|
||||
return errors
|
||||
else:
|
||||
return errors[:limit]
|
||||
|
||||
def get_archive_days(self, count: int = 31):
|
||||
|
|
|
@ -11,7 +11,7 @@ def repo_json(request, repo_label):
|
|||
repo_dict = {'location': repo.location,
|
||||
'latest_backup': repo.last_backup(),
|
||||
'size': repo.size_string(),
|
||||
'recent_errors': "not implemented",
|
||||
'recent_errors': len(repo.recent_errors()),
|
||||
'warning': repo.warning(),
|
||||
'error': repo.error()}
|
||||
return JsonResponse(repo_dict)
|
||||
|
|
Loading…
Reference in New Issue
Block a user