mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
✨ — Add waiting tasks count on index page and app API
This commit is contained in:
parent
876ac3cf54
commit
4c378e94ac
5 changed files with 29 additions and 1 deletions
|
@ -7,10 +7,11 @@
|
||||||
- 🔊 — Improve check agent log
|
- 🔊 — Improve check agent log
|
||||||
- 🔒️ — Logging out now invalidate tokens
|
- 🔒️ — Logging out now invalidate tokens
|
||||||
- 📝 — Improve OpenAPI doc
|
- 📝 — Improve OpenAPI doc
|
||||||
- 🤕 — Fix order of tasks sent to agent
|
- 🩹 — Fix order of tasks sent to agent
|
||||||
- ✨ — Add application API (fix #86)
|
- ✨ — Add application API (fix #86)
|
||||||
- ⚡️ — Faster websites configuration reloading (#85)
|
- ⚡️ — Faster websites configuration reloading (#85)
|
||||||
- 💄 — Better mobile display
|
- 💄 — Better mobile display
|
||||||
|
- ✨ — Add waiting tasks count on index page and app API
|
||||||
|
|
||||||
## 0.9.0
|
## 0.9.0
|
||||||
|
|
||||||
|
|
|
@ -594,6 +594,19 @@ async def get_severity_counts(db: Session) -> dict:
|
||||||
return counts_dict
|
return counts_dict
|
||||||
|
|
||||||
|
|
||||||
|
async def get_waiting_tasks_count(db: Session) -> int:
|
||||||
|
"""Get the count of tasks waiting to be processed"""
|
||||||
|
waiting_tasks = (
|
||||||
|
db.query(Task.id)
|
||||||
|
.filter(
|
||||||
|
Task.selected_by == None,
|
||||||
|
((Task.next_run <= datetime.now()) | (Task.next_run == None)),
|
||||||
|
)
|
||||||
|
.count()
|
||||||
|
)
|
||||||
|
return waiting_tasks
|
||||||
|
|
||||||
|
|
||||||
async def reschedule_all(db: Session):
|
async def reschedule_all(db: Session):
|
||||||
"""Reschedule checks of all non OK tasks ASAP"""
|
"""Reschedule checks of all non OK tasks ASAP"""
|
||||||
db.query(Task).filter(Task.severity != "ok").update(
|
db.query(Task).filter(Task.severity != "ok").update(
|
||||||
|
|
|
@ -170,6 +170,7 @@ async def logout(
|
||||||
class SeverityCounts(BaseModel):
|
class SeverityCounts(BaseModel):
|
||||||
severities: Dict[Literal["ok", "warning", "critical", "unknown"], int]
|
severities: Dict[Literal["ok", "warning", "critical", "unknown"], int]
|
||||||
agents: int
|
agents: int
|
||||||
|
waiting_tasks: int
|
||||||
|
|
||||||
model_config = {
|
model_config = {
|
||||||
"json_schema_extra": {
|
"json_schema_extra": {
|
||||||
|
@ -177,6 +178,7 @@ class SeverityCounts(BaseModel):
|
||||||
{
|
{
|
||||||
"severities": {"ok": 10, "warning": 0, "critical": 2, "unknown": 0},
|
"severities": {"ok": 10, "warning": 0, "critical": 2, "unknown": 0},
|
||||||
"agents": 1,
|
"agents": 1,
|
||||||
|
"waiting_tasks": 3,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -194,9 +196,12 @@ async def get_severity_counts(
|
||||||
|
|
||||||
agents = db.query(Result.agent_id).distinct().all()
|
agents = db.query(Result.agent_id).distinct().all()
|
||||||
|
|
||||||
|
waiting_tasks = await queries.get_waiting_tasks_count(db)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"severities": counts_dict,
|
"severities": counts_dict,
|
||||||
"agents": len(agents),
|
"agents": len(agents),
|
||||||
|
"waiting_tasks": waiting_tasks,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -158,12 +158,15 @@ async def get_severity_counts_view(
|
||||||
|
|
||||||
agents = db.query(Result.agent_id).distinct().all()
|
agents = db.query(Result.agent_id).distinct().all()
|
||||||
|
|
||||||
|
waiting_tasks = await queries.get_waiting_tasks_count(db)
|
||||||
|
|
||||||
return templates.TemplateResponse(
|
return templates.TemplateResponse(
|
||||||
"index.html",
|
"index.html",
|
||||||
{
|
{
|
||||||
"request": request,
|
"request": request,
|
||||||
"counts_dict": counts_dict,
|
"counts_dict": counts_dict,
|
||||||
"agents": agents,
|
"agents": agents,
|
||||||
|
"waiting_tasks": waiting_tasks,
|
||||||
"auto_refresh_enabled": auto_refresh_enabled,
|
"auto_refresh_enabled": auto_refresh_enabled,
|
||||||
"auto_refresh_seconds": auto_refresh_seconds,
|
"auto_refresh_seconds": auto_refresh_seconds,
|
||||||
"user": user,
|
"user": user,
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
{{ agents | length }} agent{{ 's' if agents | length > 1 }}
|
{{ agents | length }} agent{{ 's' if agents | length > 1 }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
{{ waiting_tasks }} task{{ 's' if waiting_tasks > 1 }} awaiting to be processed
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
|
@ -51,6 +54,9 @@
|
||||||
{{ agents | length }} agent{{ 's' if agents | length > 1 }}
|
{{ agents | length }} agent{{ 's' if agents | length > 1 }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
{{ waiting_tasks }} task{{ 's' if waiting_tasks > 1 }} awaiting to be processed
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div>
|
<div>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
Loading…
Reference in a new issue