mirror of https://github.com/jumpserver/jumpserver
perf: 优化批量更新 (#9418)
* perf: 优化批量更新 * perf: 优化代码,减少 80%,依然可用 --------- Co-authored-by: ibuler <ibuler@qq.com>pull/9420/head
parent
422bf92104
commit
93932f1904
|
@ -119,8 +119,8 @@ class AssetSerializer(BulkOrgResourceModelSerializer, WritableNestedModelSeriali
|
|||
'nodes_display', 'accounts'
|
||||
]
|
||||
read_only_fields = [
|
||||
'category', 'type', 'connectivity', 'date_verified',
|
||||
'created_by', 'date_created'
|
||||
'category', 'type', 'connectivity',
|
||||
'date_verified', 'created_by', 'date_created'
|
||||
]
|
||||
fields = fields_small + fields_fk + fields_m2m + read_only_fields
|
||||
extra_kwargs = {
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
|
||||
from rest_framework import serializers
|
||||
from rest_framework.serializers import Serializer
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
from rest_framework_bulk.serializers import BulkListSerializer
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from drf_writable_nested.serializers import WritableNestedModelSerializer as NestedModelSerializer
|
||||
from rest_framework import serializers
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
from rest_framework.serializers import Serializer
|
||||
from rest_framework_bulk.serializers import BulkListSerializer
|
||||
|
||||
from .mixin import BulkListSerializerMixin, BulkSerializerMixin
|
||||
|
||||
|
||||
__all__ = [
|
||||
'MethodSerializer', 'EmptySerializer', 'BulkModelSerializer',
|
||||
'AdaptedBulkListSerializer', 'CeleryTaskExecutionSerializer',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from collections import Iterable
|
||||
from collections import Iterable, defaultdict
|
||||
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db.models import NOT_PROVIDED
|
||||
|
@ -362,7 +362,7 @@ class CommonModelSerializer(CommonSerializerMixin, serializers.ModelSerializer):
|
|||
|
||||
|
||||
class CommonBulkSerializerMixin(BulkSerializerMixin, CommonSerializerMixin):
|
||||
pass
|
||||
_save_kwargs = defaultdict(dict)
|
||||
|
||||
|
||||
class CommonBulkModelSerializer(CommonBulkSerializerMixin, serializers.ModelSerializer):
|
||||
|
|
|
@ -4,9 +4,9 @@ from django.utils.translation import ugettext_lazy as _
|
|||
from rest_framework import serializers
|
||||
from rest_framework.validators import UniqueTogetherValidator
|
||||
|
||||
from common.validators import ProjectUniqueValidator
|
||||
from common.serializers import BulkSerializerMixin, CommonSerializerMixin, CommonModelSerializer, \
|
||||
from common.serializers import CommonModelSerializer, \
|
||||
CommonBulkModelSerializer
|
||||
from common.validators import ProjectUniqueValidator
|
||||
from ..utils import get_current_org_id_for_serializer
|
||||
|
||||
__all__ = [
|
||||
|
|
Loading…
Reference in New Issue