Skip to content

Commit 9bb565b

Browse files
committed
Add filter for fast itreation
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent 7e7f846 commit 9bb565b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

vulnerabilities/pipelines/remove_duplicate_advisories.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,17 @@ def recompute_content_ids(self):
7070

7171
advisories = []
7272

73+
advisories = Advisory.objects.exclude(unique_content_id__length=64)
74+
7375
progress = LoopProgress(
74-
total_iterations=Advisory.objects.count(),
75-
progress_step=1,
76+
total_iterations=advisories.count(),
77+
progress_step=1000,
7678
logger=self.log,
7779
)
7880

7981
batch_size = 1000
8082

81-
for advisory in progress.iter(Advisory.objects.all().paginated()):
83+
for advisory in progress.iter(advisories.paginated()):
8284
advisory.unique_content_id = compute_content_id(advisory.to_advisory_data())
8385
advisories.append(advisory)
8486
if len(advisories) % batch_size == 0:

0 commit comments

Comments
 (0)