import - rancher dashboards
This commit is contained in:
@@ -2,6 +2,8 @@ from django.db.models import Sum, Count, Q
|
|||||||
from django.db.models.functions import Coalesce
|
from django.db.models.functions import Coalesce
|
||||||
|
|
||||||
from apps.herd.models import Rancher, Herd
|
from apps.herd.models import Rancher, Herd
|
||||||
|
from apps.herd.services.services import rancher_quota_weight
|
||||||
|
from apps.product.models import OrganizationQuotaStats
|
||||||
from apps.warehouse.models import InventoryQuotaSaleItem
|
from apps.warehouse.models import InventoryQuotaSaleItem
|
||||||
|
|
||||||
|
|
||||||
@@ -76,13 +78,21 @@ class RancherDashboardService:
|
|||||||
get rancher dashboard by quota usage
|
get rancher dashboard by quota usage
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# get rancher transaction items
|
||||||
transaction_sale_items = InventoryQuotaSaleItem.objects.select_related(
|
transaction_sale_items = InventoryQuotaSaleItem.objects.select_related(
|
||||||
'transaction', 'quota_stat'
|
'transaction', 'quota_stat'
|
||||||
).filter(
|
).filter(
|
||||||
transaction__rancher=rancher,
|
transaction__rancher=rancher,
|
||||||
transaction__transaction_status='success',
|
# transaction__transaction_status='success',
|
||||||
).values('quota_stat')
|
).distinct('quota_stat').values_list('quota_stat')
|
||||||
|
|
||||||
print(list(set(transaction_sale_items)))
|
# get organization quota stats of transaction item
|
||||||
|
quota_stat = OrganizationQuotaStats.objects.filter(id__in=transaction_sale_items)
|
||||||
|
|
||||||
return {}
|
rancher_data_by_quota_usage = []
|
||||||
|
for stat in quota_stat:
|
||||||
|
rancher_quota_data = rancher_quota_weight(rancher=rancher, quota=stat.quota, quota_stat=stat)
|
||||||
|
rancher_quota_data.update({'product': stat.quota.product.name})
|
||||||
|
rancher_data_by_quota_usage.append(rancher_quota_data)
|
||||||
|
|
||||||
|
return rancher_data_by_quota_usage
|
||||||
|
|||||||
Reference in New Issue
Block a user