perf: 去掉资产查询的默认排序

This commit is contained in:
ibuler
2024-01-25 10:59:09 +08:00
committed by 老广
parent 7897462e32
commit 77569c554b
4 changed files with 6 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import abc
from django.conf import settings
from rest_framework.generics import ListAPIView, RetrieveAPIView
from assets.api.asset.asset import AssetFilterSet
@@ -47,6 +48,8 @@ class BaseUserPermedAssetsApi(SelfOrPKUserMixin, ListAPIView):
def get_queryset(self):
if getattr(self, 'swagger_fake_view', False):
return Asset.objects.none()
if settings.ASSET_SIZE == 'small':
self.ordering = ['name']
assets = self.get_assets()
assets = self.serializer_class.setup_eager_loading(assets)
return assets