diff --git a/vulnerabilities/templates/pipeline_dashboard.html b/vulnerabilities/templates/pipeline_dashboard.html index a7f4139a4..07e52b023 100644 --- a/vulnerabilities/templates/pipeline_dashboard.html +++ b/vulnerabilities/templates/pipeline_dashboard.html @@ -6,71 +6,100 @@ {% block extrahead %} -{% endblock %} +{% endblock %} {% block content %} +
+
+
+
+

Pipeline Dashboard

+
+
+
+
+
{{ form.search }}
+
+ +
+
+
-{% block content %} -
-
+
+
-
-
-

Pipeline Dashboard

-
+
+
+
+ Active Pipelines + {{ active_pipeline_count|default:0 }}
-
-
-
- {{ form.search }} -
-
- +
+ Disabled Pipelines + {{ disabled_pipeline_count|default:0 }} +
+
+ + + +
+
+
+
Pipeline ID
+
Active
+
Interval
+
Status
+
Last Run End Time
+
Next Run Start
-
- - -
-
-

- {{ active_pipeline_count|default:0 }} active pipeline{{ active_pipeline_count|default:0|pluralize }}, - {{ disabled_pipeline_count|default:0 }} disabled pipeline{{ disabled_pipeline_count|default:0|pluralize }} -

-
- - - - - - + + + + {% for schedule in schedule_list %} @@ -115,27 +144,32 @@

Pipeline Dashboard

{% endfor %} - -
-
-
-
Pipeline ID
-
Active
-
Interval
-
Status
-
Last Run End Time
-
Next Run Start
-
-
-
-
+
+
{% if is_paginated %} {% endif %} -
-
+
+
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/vulnerabilities/views.py b/vulnerabilities/views.py index 8a867983e..17e19b37f 100644 --- a/vulnerabilities/views.py +++ b/vulnerabilities/views.py @@ -12,6 +12,8 @@ from cvss.exceptions import CVSS3MalformedError from cvss.exceptions import CVSS4MalformedError from django.contrib import messages +import django_rq +from rq.worker import Worker from django.contrib.auth.views import LoginView from django.core.exceptions import ValidationError from django.core.mail import send_mail @@ -755,6 +757,20 @@ def get_context_data(self, **kwargs): context["disabled_pipeline_count"] = PipelineSchedule.objects.filter( is_active=False ).count() + + queues = [django_rq.get_queue("default")] + workers = Worker.all(connection=django_rq.get_connection()) + context["total_workers"] = len(workers) + context["idle_workers"] = len([w for w in workers if w.state == "idle"]) + context["busy_workers"] = len([w for w in workers if w.state == "busy"]) + context["queue_count"] = sum(q.count for q in queues) + + paginator = context.get("paginator") + page_obj = context.get("page_obj") + if paginator and page_obj: + context["elided_page_range"] = paginator.get_elided_page_range( + page_obj.number, on_each_side=2, on_ends=1 + ) return context