fix - remaining dist weight in dist dashboard
This commit is contained in:
@@ -3,6 +3,7 @@ from django.db.models import Sum, Count, Q
|
|||||||
from django.db.models.functions import Coalesce
|
from django.db.models.functions import Coalesce
|
||||||
|
|
||||||
from apps.authentication.models import Organization
|
from apps.authentication.models import Organization
|
||||||
|
from apps.authentication.services.service import get_all_org_child
|
||||||
from apps.core.services.filter.search import DynamicSearchService
|
from apps.core.services.filter.search import DynamicSearchService
|
||||||
from apps.product.models import OrganizationQuotaStats, QuotaDistribution, Quota
|
from apps.product.models import OrganizationQuotaStats, QuotaDistribution, Quota
|
||||||
|
|
||||||
@@ -21,6 +22,10 @@ class QuotaDashboardService:
|
|||||||
distribution_number = 0
|
distribution_number = 0
|
||||||
base_filter = {} # filter queries
|
base_filter = {} # filter queries
|
||||||
|
|
||||||
|
# child organizations
|
||||||
|
org_child = get_all_org_child(org)
|
||||||
|
org_child.append(org)
|
||||||
|
|
||||||
if product_id:
|
if product_id:
|
||||||
base_filter['quota__product_id'] = product_id
|
base_filter['quota__product_id'] = product_id
|
||||||
|
|
||||||
@@ -45,6 +50,7 @@ class QuotaDashboardService:
|
|||||||
Q(registerer_organization=org) |
|
Q(registerer_organization=org) |
|
||||||
Q(assigned_organizations=org)
|
Q(assigned_organizations=org)
|
||||||
).distinct('id'),
|
).distinct('id'),
|
||||||
|
organization__in=org_child,
|
||||||
stat_type='distribution',
|
stat_type='distribution',
|
||||||
**base_filter
|
**base_filter
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user