change map structure of rancher statistics
This commit is contained in:
@@ -22,7 +22,7 @@ def get_rancher_statistics(rancher: Rancher = None) -> typing.Any:
|
||||
camel_count=Count('id', filter=Q(type__name='شتر')),
|
||||
horse_count=Count('id', filter=Q(type__name='بز')),
|
||||
)
|
||||
return stats
|
||||
return [{'name': key, 'value': value} for key, value in stats.items()], stats
|
||||
|
||||
|
||||
def rancher_quota_weight(rancher, inventory_entry: InventoryEntry = None, distribution: QuotaDistribution = None):
|
||||
@@ -53,7 +53,7 @@ def rancher_quota_weight(rancher, inventory_entry: InventoryEntry = None, distri
|
||||
# list of quota incentive plans
|
||||
incentive_plans = list(quota.incentive_assignments.all().select_related('livestock_type'))
|
||||
|
||||
livestock_counts = get_rancher_statistics(rancher)
|
||||
livestock_counts_list, livestock_counts_dict = get_rancher_statistics(rancher)
|
||||
|
||||
total_weight = 0
|
||||
merged = {}
|
||||
@@ -62,7 +62,7 @@ def rancher_quota_weight(rancher, inventory_entry: InventoryEntry = None, distri
|
||||
if item.livestock_type:
|
||||
animal_type = item.livestock_type.name
|
||||
per_head = item.quantity_kg
|
||||
count = livestock_counts.get(live_stock_meta.get(animal_type), 0)
|
||||
count = livestock_counts_dict.get(live_stock_meta.get(animal_type), 0)
|
||||
|
||||
weight = per_head * count
|
||||
total_weight += weight
|
||||
|
||||
Reference in New Issue
Block a user