From b0a9a83231e391a5eca8730f43eb15ec4676ab92 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 14 Apr 2021 16:28:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(terminal):=20=E4=BF=AE=E5=A4=8D=E7=BB=88?= =?UTF-8?q?=E7=AB=AF=E5=88=97=E8=A1=A8=E7=9C=8B=E5=88=B0=E7=9A=84=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E4=BC=9A=E8=AF=9D=E6=95=B0=E9=87=8F=E4=B8=8D=E5=AF=B9?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/serializers/terminal.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/terminal/serializers/terminal.py b/apps/terminal/serializers/terminal.py index aee43e833..25b72ab2c 100644 --- a/apps/terminal/serializers/terminal.py +++ b/apps/terminal/serializers/terminal.py @@ -32,7 +32,7 @@ class StatusSerializer(serializers.ModelSerializer): class TerminalSerializer(BulkModelSerializer): - session_online = serializers.SerializerMethodField() + session_online = serializers.ReadOnlyField(source='get_online_session_count') is_alive = serializers.BooleanField(read_only=True) status = serializers.CharField(read_only=True, source='latest_status') status_display = serializers.CharField(read_only=True, source='latest_status_display') @@ -73,10 +73,6 @@ class TerminalSerializer(BulkModelSerializer): else: raise serializers.ValidationError(_('Not found')) - @staticmethod - def get_session_online(obj): - return Session.objects.filter(terminal=obj, is_finished=False).count() - class TaskSerializer(BulkModelSerializer): class Meta: