Skip to content

Commit acb8249

Browse files
authored
Merge pull request #593 from MohannadAK/fix-use-iterator
Fixes Issue #587
2 parents 1a3233c + b441588 commit acb8249

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

packagedb/models.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,6 @@ def get_or_none(self, *args, **kwargs):
7171
except Package.DoesNotExist:
7272
return
7373

74-
def paginated(self, per_page=5000):
75-
"""
76-
Iterate over a (large) QuerySet by chunks of ``per_page`` items.
77-
This technique is essential for preventing memory issues when iterating
78-
See these links for inspiration:
79-
https://nextlinklabs.com/resources/insights/django-big-data-iteration
80-
https://stackoverflow.com/questions/4222176/why-is-iterating-through-a-large-django-queryset-consuming-massive-amounts-of-me/
81-
"""
82-
paginator = Paginator(self, per_page=per_page)
83-
for page_number in paginator.page_range:
84-
page = paginator.page(page_number)
85-
yield from page.object_list
86-
8774

8875
VCS_CHOICES = [
8976
("git", "git"),

purl2vcs/src/purl2vcs/find_source_repo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def get_source_package_for_all_packages():
188188
Add the PackageURL of the source repository of a Package
189189
if found
190190
"""
191-
for package in Package.objects.all().paginated():
191+
for package in Package.objects.all().iterator():
192192
get_source_package_and_add_to_package_set(package)
193193

194194

0 commit comments

Comments
 (0)