|
15 | 15 | from cvss.exceptions import CVSS4MalformedError |
16 | 16 | from django.contrib import messages |
17 | 17 | from django.contrib.auth.views import LoginView |
| 18 | +from django.core.cache import cache |
18 | 19 | from django.core.exceptions import ValidationError |
19 | 20 | from django.core.mail import send_mail |
20 | 21 | from django.db.models import Exists |
|
48 | 49 | from vulnerabilities.pipelines.v2_importers.epss_importer_v2 import EPSSImporterPipeline |
49 | 50 | from vulnerabilities.severity_systems import EPSS |
50 | 51 | from vulnerabilities.severity_systems import SCORING_SYSTEMS |
| 52 | +from vulnerabilities.tasks import compute_queue_load_factor |
51 | 53 | from vulnerabilities.throttling import AnonUserUIThrottle |
52 | 54 | from vulnerabilities.utils import TYPES_WITH_MULTIPLE_IMPORTERS |
53 | 55 | from vulnerabilities.utils import get_advisories_from_groups |
|
57 | 59 |
|
58 | 60 | PAGE_SIZE = 10 |
59 | 61 |
|
| 62 | +CACHE_TIMEOUT = 60 * 5 |
| 63 | + |
60 | 64 |
|
61 | 65 | class VulnerableCodeView(View): |
62 | 66 | """ |
@@ -961,6 +965,13 @@ def get_queryset(self): |
961 | 965 |
|
962 | 966 | def get_context_data(self, **kwargs): |
963 | 967 | context = super().get_context_data(**kwargs) |
| 968 | + load_per_queue = cache.get("load_per_queue") |
| 969 | + |
| 970 | + if load_per_queue is None: |
| 971 | + load_per_queue = compute_queue_load_factor() |
| 972 | + cache.set("load_per_queue", load_per_queue, CACHE_TIMEOUT) |
| 973 | + |
| 974 | + context["load_per_queue"] = load_per_queue |
964 | 975 | context["active_pipeline_count"] = PipelineSchedule.objects.filter(is_active=True).count() |
965 | 976 | context["disabled_pipeline_count"] = PipelineSchedule.objects.filter( |
966 | 977 | is_active=False |
|
0 commit comments