Browse Source

fix: 用户组列表 用户数量不准确

pull/12556/head
feng 10 months ago committed by Bryan
parent
commit
641e75a905
  1. 4
      apps/users/serializers/group.py

4
apps/users/serializers/group.py

@ -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

Loading…
Cancel
Save