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