fix - improve excel response time
This commit is contained in:
@@ -7,7 +7,7 @@ ENV_NAME=DEV
|
||||
# Database secrets
|
||||
DB_HOST=31.7.78.133
|
||||
DB_PORT=14352
|
||||
DB_NAME=Development
|
||||
DB_NAME=Production
|
||||
DB_USERNAME=postgres
|
||||
DB_PASSWORD=pfLIVXupbDetvFMt2gUvxLXUL9b4HIOHaPcKXsBEZ1i8zl0iLUjmhUfXlGfJKcTV
|
||||
|
||||
|
||||
@@ -442,6 +442,7 @@ class WareHouseExcelViewSet(viewsets.ViewSet):
|
||||
'rancher__city',
|
||||
'seller_organization__name',
|
||||
'seller_organization__city',
|
||||
'transaction_status',
|
||||
)
|
||||
|
||||
transaction_ids = [t['id'] for t in qs_values]
|
||||
@@ -452,7 +453,10 @@ class WareHouseExcelViewSet(viewsets.ViewSet):
|
||||
).values(
|
||||
'transaction_id',
|
||||
'name',
|
||||
'unit_price'
|
||||
'item_share',
|
||||
'unit_price',
|
||||
'paid_price',
|
||||
'unit'
|
||||
)
|
||||
|
||||
# Aggregate share totals per transaction
|
||||
@@ -460,7 +464,8 @@ class WareHouseExcelViewSet(viewsets.ViewSet):
|
||||
share_names_set = set()
|
||||
for item in items_qs:
|
||||
transaction_shares_map[item['transaction_id']].append(item)
|
||||
share_names_set.add(item['name'])
|
||||
for i in item['item_share']:
|
||||
share_names_set.add(i['name'])
|
||||
|
||||
share_names = list(share_names_set)
|
||||
|
||||
@@ -518,7 +523,10 @@ class WareHouseExcelViewSet(viewsets.ViewSet):
|
||||
# جمع share totals هر تراکنش
|
||||
share_values = []
|
||||
for share_name in share_names:
|
||||
share_total = sum(i['unit_price'] for i in t_items if i['name'] == share_name)
|
||||
# print(t_items, '\n', share_name)
|
||||
for i in t_items:
|
||||
share_total = sum(
|
||||
share['price'] for share in i['item_share'] if share['name'] == share_name)
|
||||
share_values.append(share_total)
|
||||
share_column_totals[share_name] += share_total
|
||||
|
||||
@@ -537,9 +545,9 @@ class WareHouseExcelViewSet(viewsets.ViewSet):
|
||||
str(shamsi_date(t['transaction_date'], in_value=True)) if t.get('transaction_date') else '',
|
||||
products_str,
|
||||
t.get('transaction_id', '-'),
|
||||
'', # شماره کارت اگر موجود باشه
|
||||
'-', # شماره کارت اگر موجود باشه
|
||||
t.get('price_paid', 0),
|
||||
'', # ماهیت وزن
|
||||
f'{total_weight}کیلوگرم', # ماهیت وزن
|
||||
TRANSACTION_STATUS_MAP.get(t.get('transaction_status'), '-'),
|
||||
]
|
||||
list1.extend(share_values)
|
||||
|
||||
Reference in New Issue
Block a user