mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 09:52:38 +02:00
Add a way to know when the last checks have been run
This commit is contained in:
parent
dd2dc14351
commit
6338d7d9e6
2 changed files with 7 additions and 1 deletions
|
@ -19,19 +19,23 @@ async def read_tasks(request: Request, db: Session = Depends(get_db)):
|
|||
tasks = db.query(Task).order_by(Task.domain).all()
|
||||
|
||||
domains_severities = defaultdict(list)
|
||||
domains_last_checks = defaultdict(list)
|
||||
for task in tasks:
|
||||
severity = task.severity or "to-process"
|
||||
domain = urlparse(task.url).netloc
|
||||
domains_severities[domain].append(severity)
|
||||
domains_last_checks[domain].append(task.last_result.submitted_at)
|
||||
|
||||
def _max_severity(severities):
|
||||
severity_level = {"ok": 1, "warning": 2, "critical": 3, "to-process": "4"}
|
||||
return max(severities, key=severity_level.get)
|
||||
|
||||
domains = {key: _max_severity(value) for key, value in domains_severities.items()}
|
||||
last_checks = {key: max(value) for key, value in domains_last_checks.items()}
|
||||
|
||||
return templates.TemplateResponse(
|
||||
"index.html", {"request": request, "domains": domains}
|
||||
"index.html",
|
||||
{"request": request, "domains": domains, "last_checks": last_checks},
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<tr>
|
||||
<th>Domain</th>
|
||||
<th class="today">Current status</th>
|
||||
<th>Last check</th>
|
||||
</thead>
|
||||
|
||||
<tbody id="domains-body">
|
||||
|
@ -18,6 +19,7 @@
|
|||
</td>
|
||||
|
||||
<td class="status highlight">{% if status == "ok" %}✅ OK {% elif statuts == "warning"%}⚠ Warning{% elif status == "critical"%}❌ Critical{% elif status == "to-process" %}⏱︎ Waiting for the jobs{% endif %}</td>
|
||||
<td>{{ last_checks.get(domain) }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
|
|
Loading…
Reference in a new issue