mirror of https://github.com/jumpserver/jumpserver
fix(terminal): 修复终端列表看到的在线会话数量不对的bug
parent
7da14571ac
commit
b0a9a83231
|
@ -32,7 +32,7 @@ class StatusSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
|
|
||||||
class TerminalSerializer(BulkModelSerializer):
|
class TerminalSerializer(BulkModelSerializer):
|
||||||
session_online = serializers.SerializerMethodField()
|
session_online = serializers.ReadOnlyField(source='get_online_session_count')
|
||||||
is_alive = serializers.BooleanField(read_only=True)
|
is_alive = serializers.BooleanField(read_only=True)
|
||||||
status = serializers.CharField(read_only=True, source='latest_status')
|
status = serializers.CharField(read_only=True, source='latest_status')
|
||||||
status_display = serializers.CharField(read_only=True, source='latest_status_display')
|
status_display = serializers.CharField(read_only=True, source='latest_status_display')
|
||||||
|
@ -73,10 +73,6 @@ class TerminalSerializer(BulkModelSerializer):
|
||||||
else:
|
else:
|
||||||
raise serializers.ValidationError(_('Not found'))
|
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 TaskSerializer(BulkModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
Loading…
Reference in New Issue