Skip to content

Commit

Permalink
Export optimizations
Browse files Browse the repository at this point in the history
Django-import-export isn't smart enough to avoid the fk lookup even if
it only sierializes the fk directly.

[noissue]
  • Loading branch information
dralley committed Oct 11, 2023
1 parent 13adaf9 commit 1dacd09
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions pulp_rpm/app/modelresource.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def set_up_queryset(self):

return content

def dehydrate__pulp_domain(self, content):
return str(content._pulp_domain_id)


class ModulemdResource(RpmContentResource):
"""
Expand Down Expand Up @@ -409,9 +412,13 @@ def set_up_queryset(self):
UpdateCollections belonging to UpdateRecords for a specified repo-version.
"""
return UpdateCollection.objects.filter(
update_record__in=UpdateRecord.objects.filter(pk__in=self.repo_version.content)
).order_by("pulp_id")
return (
UpdateCollection.objects.filter(
update_record__in=UpdateRecord.objects.filter(pk__in=self.repo_version.content)
)
.order_by("pulp_id")
.select_related("update_record")
)

class Meta:
model = UpdateCollection
Expand All @@ -438,9 +445,13 @@ def set_up_queryset(self):
UpdateReferences belonging to UpdateRecords for a specified repo-version.
"""
return UpdateReference.objects.filter(
update_record__in=UpdateRecord.objects.filter(pk__in=self.repo_version.content)
).order_by("pulp_id")
return (
UpdateReference.objects.filter(
update_record__in=UpdateRecord.objects.filter(pk__in=self.repo_version.content)
)
.order_by("pulp_id")
.select_related("update_record")
)

class Meta:
model = UpdateReference
Expand Down Expand Up @@ -529,6 +540,7 @@ def set_up_queryset(self):
)
.distinct("name", "epoch", "version", "release", "arch")
.order_by("name", "epoch", "version", "release", "arch")
.select_related("update_collection")
)

class Meta:
Expand Down

0 comments on commit 1dacd09

Please sign in to comment.