Skip to content

Commit 2fb7da1

Browse files
committed
Address review comments
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent 4d892ec commit 2fb7da1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

vulnerabilities/pipelines/remove_duplicate_advisories.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,14 @@ def recompute_content_ids(self):
7676
logger=self.log,
7777
)
7878

79+
batch_size = 1000
80+
7981
for advisory in progress.iter(Advisory.objects.all().paginated()):
8082
advisory.unique_content_id = compute_content_id(advisory)
8183
advisories.append(advisory)
84+
if len(advisories) % batch_size == 0:
85+
Advisory.objects.bulk_update(advisories, ["unique_content_id"], batch_size=batch_size)
86+
advisories = []
8287

83-
Advisory.objects.bulk_update(advisories, ["unique_content_id"], batch_size=1000)
88+
if advisories:
89+
Advisory.objects.bulk_update(advisories, ["unique_content_id"], batch_size=batch_size)

0 commit comments

Comments
 (0)