Skip to content

Commit 98d19dd

Browse files
committed
feat: use additional worker count to indicate load factor
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent fd2cca5 commit 98d19dd

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

vulnerabilities/templates/pipeline_dashboard.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ <h1>Pipeline Dashboard</h1>
8686
worker{{ additional|pluralize }} for the {{ queue_name }} queue.">
8787
<span class="icon"><i class="fa fa-exclamation-triangle"></i></span>
8888
</span>
89-
{% elif load_factor < 1 %}
89+
{% elif additional < 1 %}
9090
<span class="has-text-weight-bold is-size-6 has-text-success has-tooltip-arrow has-tooltip-multiline has-tooltip-success"
9191
data-tooltip="{{ queue_name|capfirst }} queue perfectly balanced.">
9292
{{ load_factor|floatformat:2 }}
9393
<span class="icon"><i class="fa fa-check-circle"></i></span>
9494
</span>
95-
{% elif load_factor < 1.6 %}
95+
{% elif additional < 2 %}
9696
<span class="has-text-weight-bold is-size-6 has-text-orange has-tooltip-arrow has-tooltip-multiline has-tooltip-orange"
9797
data-tooltip="Consider adding {{ additional }} additional worker{{ additional|pluralize }} to the {{ queue_name }} queue.">
9898
{{ load_factor|floatformat:2 }}

vulnerabilities/views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959

6060
PAGE_SIZE = 10
6161

62-
CACHE_TIMEOUT = 60 * 5
63-
6462

6563
class VulnerableCodeView(View):
6664
"""
@@ -965,11 +963,12 @@ def get_queryset(self):
965963

966964
def get_context_data(self, **kwargs):
967965
context = super().get_context_data(**kwargs)
966+
cache_timeout = 60 * 10
968967
load_per_queue = cache.get("load_per_queue")
969968

970969
if load_per_queue is None:
971970
load_per_queue = compute_queue_load_factor()
972-
cache.set("load_per_queue", load_per_queue, CACHE_TIMEOUT)
971+
cache.set("load_per_queue", load_per_queue, cache_timeout)
973972

974973
context["load_per_queue"] = load_per_queue
975974
context["active_pipeline_count"] = PipelineSchedule.objects.filter(is_active=True).count()

0 commit comments

Comments
 (0)