123
This commit is contained in:
14
background/update.py
Normal file
14
background/update.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import time
|
||||
|
||||
from backend.session import get_session
|
||||
from schemas.general import StockUpdate
|
||||
from updaters.stocks_updater import StocksUpdater
|
||||
|
||||
|
||||
async def process_update(product_ids: list[int]):
|
||||
async for session in get_session():
|
||||
updates = [StockUpdate(product_id=product_id) for product_id in product_ids]
|
||||
updater = StocksUpdater(session)
|
||||
await updater.update(updates)
|
||||
await session.close()
|
||||
return {'message': f'Stocks for [{",".join(map(str, product_ids))}] successfully updated'}
|
||||
Reference in New Issue
Block a user