mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 01:42:38 +02:00
🐛 — Fix domains sorting on domains view
This commit is contained in:
parent
94aae86564
commit
9316aa9a79
2 changed files with 10 additions and 4 deletions
|
@ -435,6 +435,7 @@ disable=raw-checker-failed,
|
|||
use-implicit-booleaness-not-comparison-to-zero,
|
||||
fixme,
|
||||
too-few-public-methods,
|
||||
too-many-locals,
|
||||
unused-argument,
|
||||
import-outside-toplevel,
|
||||
no-self-argument,
|
||||
|
|
|
@ -15,6 +15,12 @@ from argos.server.routes.dependencies import get_config, get_db
|
|||
route = APIRouter()
|
||||
|
||||
templates = Jinja2Templates(directory="argos/server/templates")
|
||||
SEVERITY_LEVELS = {
|
||||
"ok": 1,
|
||||
"warning": 2,
|
||||
"critical": 3,
|
||||
"to-process": 4
|
||||
}
|
||||
|
||||
|
||||
@route.get("/")
|
||||
|
@ -44,7 +50,7 @@ async def get_severity_counts(
|
|||
@route.get("/details")
|
||||
async def read_tasks(request: Request, db: Session = Depends(get_db)):
|
||||
"""Show all tasks and their current state"""
|
||||
tasks = db.query(Task).order_by(Task.domain).all()
|
||||
tasks = db.query(Task).order_by(Task.domain.desc()).all()
|
||||
|
||||
results = (
|
||||
db.query(Task, Result)
|
||||
|
@ -63,12 +69,11 @@ async def read_tasks(request: Request, db: Session = Depends(get_db)):
|
|||
domains_last_checks[domain].append(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)
|
||||
return max(severities, key=SEVERITY_LEVELS.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()}
|
||||
domains.sort(key=lambda x: x[1])
|
||||
domains.sort(key=lambda x: SEVERITY_LEVELS[x[1]], reverse=True)
|
||||
|
||||
agents = db.query(Result.agent_id).distinct().all()
|
||||
|
||||
|
|
Loading…
Reference in a new issue