perf: 优化 msg

pull/9753/head
ibuler 2023-02-24 14:33:37 +08:00 committed by Jiangjie.Bai
parent 63ca4f8fab
commit 22a1d60e3f
6 changed files with 20 additions and 10 deletions

View File

@ -29,7 +29,8 @@ class LabelSerializer(BulkOrgResourceModelSerializer):
@classmethod @classmethod
def setup_eager_loading(cls, queryset): def setup_eager_loading(cls, queryset):
queryset = queryset.annotate(asset_count=Count('assets')) queryset = queryset.prefetch_related('assets') \
.annotate(asset_count=Count('assets'))
return queryset return queryset

View File

@ -55,9 +55,11 @@ class BulkSerializerMixin(object):
# add update_lookup_field field back to validated data # add update_lookup_field field back to validated data
# since super by default strips out read-only fields # since super by default strips out read-only fields
# hence id will no longer be present in validated_data # hence id will no longer be present in validated_data
if all((isinstance(self.root, BulkListSerializer), if all([
id_attr, isinstance(self.root, BulkListSerializer),
request_method in ('PUT', 'PATCH'))): id_attr,
request_method in ('PUT', 'PATCH')
]):
id_field = self.fields.get("id") or self.fields.get('pk') id_field = self.fields.get("id") or self.fields.get('pk')
if data.get("id"): if data.get("id"):
id_value = id_field.to_internal_value(data.get("id")) id_value = id_field.to_internal_value(data.get("id"))
@ -135,7 +137,7 @@ class BulkListSerializerMixin:
pk = item["pk"] pk = item["pk"]
else: else:
raise ValidationError("id or pk not in data") raise ValidationError("id or pk not in data")
child = self.instance.get(id=pk) child = self.instance.get(pk=pk)
self.child.instance = child self.child.instance = child
self.child.initial_data = item self.child.initial_data = item
# raw # raw

View File

@ -32,7 +32,7 @@ class Counter:
return self.counter == other.counter return self.counter == other.counter
def on_request_finished_logging_db_query(sender, **kwargs): def digest_sql_query():
queries = connection.queries queries = connection.queries
counters = defaultdict(Counter) counters = defaultdict(Counter)
table_queries = defaultdict(list) table_queries = defaultdict(list)
@ -79,6 +79,9 @@ def on_request_finished_logging_db_query(sender, **kwargs):
counter.counter, counter.time, name) counter.counter, counter.time, name)
) )
def on_request_finished_logging_db_query(sender, **kwargs):
digest_sql_query()
on_request_finished_release_local(sender, **kwargs) on_request_finished_release_local(sender, **kwargs)

View File

@ -20,7 +20,7 @@ default_context = {
'LOGIN_WECOM_logo_logout': static('img/login_wecom_logo.png'), 'LOGIN_WECOM_logo_logout': static('img/login_wecom_logo.png'),
'LOGIN_DINGTALK_logo_logout': static('img/login_dingtalk_logo.png'), 'LOGIN_DINGTALK_logo_logout': static('img/login_dingtalk_logo.png'),
'LOGIN_FEISHU_logo_logout': static('img/login_feishu_logo.png'), 'LOGIN_FEISHU_logo_logout': static('img/login_feishu_logo.png'),
'COPYRIGHT': 'FIT2CLOUD 飞致云' + ' © 2014-2022', 'COPYRIGHT': 'FIT2CLOUD 飞致云' + ' © 2014-2023',
'INTERFACE': default_interface, 'INTERFACE': default_interface,
} }

View File

@ -18,6 +18,10 @@
margin: 0 auto; margin: 0 auto;
padding: 100px 20px 20px 20px; padding: 100px 20px 20px 20px;
} }
.ibox-content {
padding: 30px;
}
</style> </style>
{% block custom_head_css_js %} {% endblock %} {% block custom_head_css_js %} {% endblock %}
</head> </head>
@ -30,7 +34,7 @@
<h2 class="font-bold"> <h2 class="font-bold">
{% block title %}{% endblock %} {% block title %}{% endblock %}
</h2> </h2>
<div style="margin: 10px 0"> <div style="margin: 20px 0 0 0">
{% block content %} {% endblock %} {% block content %} {% endblock %}
</div> </div>
</div> </div>

View File

@ -23,7 +23,7 @@
<div class="row"> <div class="row">
{% if has_cancel %} {% if has_cancel %}
<div class="col-sm-3"> <div class="col-sm-3">
<a href="{{ cancel_url }}" class="btn btn-default block full-width m-b"> <a href="{{ cancel_url }}" class="btn btn-default block full-width m-b">
{% trans 'Cancel' %} {% trans 'Cancel' %}
</a> </a>
@ -43,7 +43,7 @@
{% endblock %} {% endblock %}
{% block custom_foot_js %} {% block custom_foot_js %}
<script> <script>
var message = '' var message = ''
var time = '{{ interval }}' var time = '{{ interval }}'
{% if error %} {% if error %}