feat: update marketplace products
This commit is contained in:
@@ -17,6 +17,12 @@ def update_marketplace(marketplace_id: int):
|
||||
return loop.run_until_complete(background.update.update_marketplace(marketplace_id))
|
||||
|
||||
|
||||
@celery.task(name='update_marketplace_products')
|
||||
def update_marketplace_products(marketplace_id: int, product_ids: list[int]):
|
||||
loop = asyncio.get_event_loop()
|
||||
return loop.run_until_complete(background.update.update_marketplace_products(marketplace_id, product_ids))
|
||||
|
||||
|
||||
@celery.task(name='update_marketplaces')
|
||||
def update_marketplaces(marketplace_ids: Union[List[int], None]):
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
@@ -20,6 +20,14 @@ async def update_marketplace(marketplace_id: int):
|
||||
return {'message': f'Stocks for marketplace {marketplace_id} successfully updated'}
|
||||
|
||||
|
||||
async def update_marketplace_products(marketplace_id: int, product_ids: list[int]):
|
||||
async with session_factory() as session:
|
||||
updater = StocksUpdater(session)
|
||||
await updater.update_marketplace_products(marketplace_id, product_ids)
|
||||
return {
|
||||
'message': f'Products [{",".join(list(map(str, product_ids)))}] successfully updated for marketplace {marketplace_id}'}
|
||||
|
||||
|
||||
async def update_marketplaces(marketplace_ids: Union[List[int], None]):
|
||||
async with session_factory() as session:
|
||||
updater = StocksUpdater(session)
|
||||
|
||||
Reference in New Issue
Block a user