Skip to content

Commit e287bf0

Browse files
Merge branch 'main' into fix/api-v3-validate-advisory-purl
2 parents 8849f27 + faab557 commit e287bf0

8 files changed

Lines changed: 33 additions & 21 deletions

File tree

‎requirements-dev.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ typecode==30.2.0
154154
typecode-libmagic==5.39.210531
155155
typing_extensions==4.13.0
156156
tzlocal==5.3.1
157+
tzdata==2026.5
157158
univers==32.0.1
158159
uritemplate==4.2.0
159160
urllib3==2.6.3

‎requirements.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ typecode==30.2.0
8181
typecode-libmagic==5.39.210531
8282
typing_extensions==4.13.0
8383
tzlocal==5.3.1
84+
tzdata==2026.5
8485
univers==32.0.1
8586
uritemplate==4.2.0
8687
urllib3==2.6.3

‎setup.cfg‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ install_requires =
6666
django-environ==0.11.2
6767
gunicorn==23.0.0
6868
django-altcha==0.2.0
69+
tzdata==2026.5
6970

7071
# for the API doc
7172
drf-spectacular[sidecar]==0.24.2

‎vulnerabilities/middleware/timezone.py‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ def __init__(self, get_response):
1717
self.get_response = get_response
1818

1919
def __call__(self, request):
20-
try:
21-
# Activate local timezone for user using cookies
22-
tzname = request.COOKIES.get("user_timezone")
23-
if tzname:
20+
tzname = request.COOKIES.get("user_timezone")
21+
if tzname:
22+
try:
2423
timezone.activate(zoneinfo.ZoneInfo(tzname))
25-
else:
24+
except Exception as e:
2625
timezone.deactivate()
27-
except Exception as e:
26+
else:
27+
timezone.deactivate()
28+
29+
try:
30+
response = self.get_response(request)
31+
finally:
2832
timezone.deactivate()
2933

30-
return self.get_response(request)
34+
return response

‎vulnerabilities/pipelines/management/cleanup_pipeline_runs.py‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,25 @@ def cleanup_old_pipeline_runs(self):
4444
)
4545
for pipeline in progress.iter(pipelines):
4646
cutoff = timezone.now() - timedelta(days=retention_days)
47-
runs = pipeline.pipelineruns.filter(run_exitcode__isnull=False).order_by(
48-
"-created_date"
47+
keep_ids = list(
48+
pipeline.pipelineruns.filter(run_exitcode__isnull=False)
49+
.order_by("-created_date")[:minimum_number_of_runs_to_keep]
50+
.values_list("run_id", flat=True)
4951
)
50-
runs_to_keep = runs[:minimum_number_of_runs_to_keep]
51-
runs_to_delete = runs.filter(created_date__lt=cutoff).exclude(
52-
run_id__in=runs_to_keep.values("run_id")
52+
runs_to_delete = pipeline.pipelineruns.filter(created_date__lt=cutoff).exclude(
53+
run_id__in=keep_ids
5354
)
5455

5556
if runs_to_delete.exists():
5657
pipeline_count += 1
5758

58-
for run in runs_to_delete.iterator():
59-
run.delete()
60-
deleted_run_count += 1
59+
while runs_to_delete.exists():
60+
chunk_ids = list(runs_to_delete[:5000].values_list("run_id", flat=True))
61+
if not chunk_ids:
62+
break
63+
64+
count, _ = pipeline.pipelineruns.filter(run_id__in=chunk_ids).delete()
65+
deleted_run_count += count
6166

6267
self.log(
6368
f"Successfully removed {deleted_run_count:,d} runs from {pipeline_count} pipelines that were older than {retention_days} days."

‎vulnerabilities/templates/pipeline_dashboard.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ <h1>Pipeline Dashboard</h1>
161161
</div>
162162
<div class="column has-text-grey" style="flex: 0 0 18%;">
163163
{% if schedule.latest_run_end_date %}
164-
{{ schedule.latest_run_end_date|date:"Y-m-d h:i a T" }}
164+
{{ schedule.latest_run_end_date|date:"Y-m-d h:i A T" }}
165165
{% else %}
166166
N/A
167167
{% endif %}

‎vulnerabilities/templates/pipeline_run_details.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ <h1 class="title">{{ pipeline_name }} Run Log</h1>
7979
<p class="is-size-7 has-text-weight-semibold">Start</p>
8080
<p class="has-text-grey is-size-7">
8181
{% if run.run_start_date %}
82-
{{ run.run_start_date|date:"Y-m-d h:i a T" }}
82+
{{ run.run_start_date|date:"Y-m-d h:i A T" }}
8383
{% else %}
8484
N/A
8585
{% endif %}
@@ -89,15 +89,15 @@ <h1 class="title">{{ pipeline_name }} Run Log</h1>
8989
<p class="is-size-7 has-text-weight-semibold">End</p>
9090
<p class="has-text-grey is-size-7">
9191
{% if run.run_end_date %}
92-
{{ run.run_end_date|date:"Y-m-d h:i a T" }}
92+
{{ run.run_end_date|date:"Y-m-d h:i A T" }}
9393
{% else %}
9494
N/A
9595
{% endif %}
9696
</p>
9797
</div>
9898
<div class="column is-one-fifth-desktop is-one-quarter-tablet is-half-mobile">
9999
<p class="is-size-7 has-text-weight-semibold">Created</p>
100-
<p class="has-text-grey is-size-7">{{ run.created_date|date:"Y-m-d h:i a T" }}</p>
100+
<p class="has-text-grey is-size-7">{{ run.created_date|date:"Y-m-d h:i A T" }}</p>
101101
</div>
102102
<div class="column is-one-fifth-desktop is-one-quarter-tablet is-half-mobile">
103103
<p class="is-size-7 has-text-weight-semibold">Version</p>

‎vulnerabilities/templates/pipeline_run_list.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ <h1>{{ pipeline_name }} Runs</h1>
9595
</div>
9696
<div class="column is-one-fifth has-text-grey">
9797
{% if run.run_start_date %}
98-
{{ run.run_start_date|date:"Y-m-d h:i a T" }}
98+
{{ run.run_start_date|date:"Y-m-d h:i A T" }}
9999
{% else %}
100100
N/A
101101
{% endif %}
102102
</div>
103103
<div class="column is-one-fifth has-text-grey">
104104
{% if run.run_end_date %}
105-
{{ run.run_end_date|date:"Y-m-d h:i a T" }}
105+
{{ run.run_end_date|date:"Y-m-d h:i A T" }}
106106
{% else %}
107107
N/A
108108
{% endif %}

0 commit comments

Comments
 (0)