From 1068662ab1af833cd6b70bcedec731f08d16d11c Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Fri, 30 Aug 2024 09:54:21 +0800 Subject: [PATCH] perf: Optimize asset connection speed with es command storage --- apps/terminal/serializers/session.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/terminal/serializers/session.py b/apps/terminal/serializers/session.py index 7bc08a2ad..91928431d 100644 --- a/apps/terminal/serializers/session.py +++ b/apps/terminal/serializers/session.py @@ -58,6 +58,15 @@ class SessionSerializer(BulkOrgResourceModelSerializer): 'terminal_display': {'label': _('Terminal display')}, } + def get_fields(self): + fields = super().get_fields() + self.pop_fields_if_need(fields) + return fields + + def pop_fields_if_need(self, fields): + if self.context['request'].method != "GET": + fields.pop("command_amount") + def validate_asset(self, value): max_length = self.Meta.model.asset.field.max_length value = pretty_string(value, max_length=max_length)