mirror of https://github.com/jumpserver/jumpserver
perf: Enhance eager loading by including labels in queryset
parent
1372fd7535
commit
965ec7007c
|
@ -41,7 +41,7 @@ class AssetPermedSerializer(OrgResourceModelSerializerMixin, ResourceLabelsMixin
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_eager_loading(cls, queryset):
|
def setup_eager_loading(cls, queryset):
|
||||||
""" Perform necessary eager loading of data. """
|
""" Perform necessary eager loading of data. """
|
||||||
queryset = queryset.prefetch_related('zone', 'nodes') \
|
queryset = queryset.prefetch_related('zone', 'nodes', "labels", "labels__label") \
|
||||||
.prefetch_related('platform') \
|
.prefetch_related('platform') \
|
||||||
.annotate(category=F("platform__category")) \
|
.annotate(category=F("platform__category")) \
|
||||||
.annotate(type=F("platform__type"))
|
.annotate(type=F("platform__type"))
|
||||||
|
|
Loading…
Reference in New Issue