mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-05-04 10:13:43 +00:00
fix: 用户组列表 用户数量不准确
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
from django.db.models import Count
|
||||
from django.db.models import Count, Q
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from rest_framework import serializers
|
||||
|
||||
@@ -46,7 +46,7 @@ class UserGroupSerializer(ResourceLabelsMixin, BulkOrgResourceModelSerializer):
|
||||
def setup_eager_loading(cls, queryset):
|
||||
""" Perform necessary eager loading of data. """
|
||||
queryset = queryset.prefetch_related('labels', 'labels__label') \
|
||||
.annotate(users_amount=Count('users'))
|
||||
.annotate(users_amount=Count('users', filter=Q(users__is_service_account=False)))
|
||||
return queryset
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user