Display recent errors

This commit is contained in:
George Lacey 2021-05-08 23:03:56 +01:00
parent 225b55da7a
commit ce66431a01
3 changed files with 13 additions and 6 deletions

View File

@ -31,9 +31,9 @@ class Repo(models.Model):
def recent_errors(self): def recent_errors(self):
days = 7 days = 7
days_ago = (datetime.utcnow() - timedelta(days=7)) 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 len(errors) return errors
def archive_dates(self): def archive_dates(self):
days = self.get_archive_days() days = self.get_archive_days()

View File

@ -5,6 +5,6 @@ div {
} }
dl { dl {
margin: 0px; margin: 4px;
font-size: 16px; font-size: 16px;
} }

View File

@ -17,7 +17,7 @@
<p id="hours"></p> <p id="hours"></p>
{% if repo_list %} {% if repo_list %}
{% for repo in repo_list %} {% for repo in repo_list %}
<div class="col-md-4 rounded float-md-left"> <div class="col-md-4 rounded float-xl-left">
<h3 class="repo_label">{{ repo.label }}<small class="text-muted"> {{ repo.location }}</small></h3> <h3 class="repo_label">{{ repo.label }}<small class="text-muted"> {{ repo.location }}</small></h3>
<dl class="row"> <dl class="row">
<dt class="col-sm-3">Latest backup:</dt> <dt class="col-sm-3">Latest backup:</dt>
@ -31,9 +31,16 @@
<dt class="col-sm-3">Size:</dt> <dt class="col-sm-3">Size:</dt>
<dd class="col-sm-9">{{ repo.size }}</dd> <dd class="col-sm-9">{{ repo.size }}</dd>
</dl> </dl>
{% if repo.recent_errors|length > 0 %}
<dl class="row"> <dl class="row">
<dt class="col-sm-3">Recent errors:</dt> <dt class="col-sm-9 h4">Recent errors:</dt>
<dd class="col-sm-9"><span class="badge badge-pill badge-secondary pull-right">{{ repo.recent_errors }}</span></dd> </dl>
{% endif %}
<dl class="row">
{% for error in repo.recent_errors %}
<dt class="col-sm-4">{{ error.time|date:'d-m-Y H:i' }}</dt>
<dd class="col-sm-8 text-truncate">{{ error.error }}</dd>
{% endfor %}
</dl> </dl>
</div> </div>
{% endfor %} {% endfor %}