feat: ability to reset marketplace

This commit is contained in:
2024-11-11 10:41:51 +03:00
parent 8cb94d06bf
commit 4841578dee
7 changed files with 47 additions and 2 deletions

View File

@@ -25,6 +25,11 @@ async def update_marketplaces(marketplace_ids: list[int]):
return await background.update.update_marketplaces(marketplace_ids)
@taskiq_broker.task(task_name='reset_marketplace')
async def reset_marketplace(marketplace_id: int):
return await background.update.reset_marketplace(marketplace_id)
@taskiq_broker.task(schedule=[{"cron": "* * * * *"}])
async def flush_buffer():
try:

View File

@@ -33,3 +33,9 @@ async def update_marketplaces(marketplace_ids: Union[List[int], None]):
updater = StocksUpdater(session)
await updater.full_update_all_marketplaces(marketplace_ids)
logging.info(f'Marketplaces {marketplace_ids} successfully updated')
async def reset_marketplace(marketplace_id:int):
async with session_factory() as session:
updater = StocksUpdater(session)
await updater.reset_marketplace(marketplace_id)
logging.info(f'Marketplace {marketplace_id} successfully reset')