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