Кэширование товаров из накладной

This commit is contained in:
2024-12-05 23:18:52 +03:00
parent f265553cfc
commit 8b3c0e0fcc

View File

@@ -21,11 +21,15 @@ def clear():
session.pop('waybill') session.pop('waybill')
def form_waybill() -> list: def form_waybill() -> list:
db_config = current_app.config['db_config']
cache_config = current_app.config['cache_config']
current_waybill = session.get('waybill',{}) current_waybill = session.get('waybill',{})
waybill = [] waybill = []
for k,v in current_waybill.items(): for k,v in current_waybill.items():
_sql = sql_provider.get('one_good.sql', dict(work_id=k)) _sql = sql_provider.get('one_good.sql', dict(work_id=k))
product = select_list(current_app.config['db_config'], _sql)[0] cache_select = fetch_from_cache(f'product_{k}', cache_config)(select_list)
product = cache_select(db_config, _sql)[0]
product['amount'] = v product['amount'] = v
waybill.append(product) waybill.append(product)
return waybill return waybill