Skip to content

Commit

Permalink
Fix data center asset export not getting filter from request
Browse files Browse the repository at this point in the history
  • Loading branch information
hipek8 committed Oct 31, 2024
1 parent c435102 commit 03da535
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 0 additions & 3 deletions src/ralph/admin/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,6 @@ def get_export_queryset(self, request):
)
if resource_prefetch_related:
queryset = queryset.prefetch_related(*resource_prefetch_related)
# cast to list to consider all prefetch_related (django-import-export
# use queryset.iterator() to "save memory", but then for every row
# sql queries are made to fetch all m2m relations)
return list(queryset)

def get_export_resource_class(self):
Expand Down
7 changes: 0 additions & 7 deletions src/ralph/data_center/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,6 @@ class DataCenterAssetAdmin(
}),
)

def get_export_queryset(self, request):
return DataCenterAsset.polymorphic_objects.select_related(
*self.list_select_related
).polymorphic_prefetch_related(
DataCenterAsset=['tags', 'ethernet_set__ipaddress', 'parent__ethernet_set__ipaddress'],
)

def get_multiadd_fields(self, obj=None):
multiadd_fields = [
{'field': 'sn', 'allow_duplicates': False},
Expand Down
8 changes: 8 additions & 0 deletions src/ralph/data_importer/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,16 @@ class DataCenterAssetResource(ResourceWithPrice, RalphModelResource):
class Meta:
model = physical.DataCenterAsset
select_related = (
'model__manufacturer', 'model__category',
'service_env__service', 'service_env__environment',
'rack__server_room__data_center',
'configuration_path',
'property_of',
'parent',
'budget_info',
)
prefetch_related = (
'tags', 'ethernet_set__ipaddress', 'parent__ethernet_set__ipaddress',
)
exclude = ('content_type', 'asset_ptr', 'baseobject_ptr', 'connections')

Expand Down

0 comments on commit 03da535

Please sign in to comment.