feat: update marketplace products
This commit is contained in:
@@ -19,7 +19,7 @@ class StocksUpdater:
|
||||
def __init__(self, session: AsyncSession):
|
||||
self.session = session
|
||||
|
||||
async def get_marketplace(self, marketplace_id: int):
|
||||
async def get_marketplace(self, marketplace_id: int) -> Marketplace:
|
||||
marketplace = await self.session.get(Marketplace, marketplace_id, options=[
|
||||
joinedload(Marketplace.warehouses).joinedload(Warehouse.suppliers),
|
||||
joinedload(Marketplace.warehouses).joinedload(Warehouse.company_warehouses),
|
||||
@@ -94,6 +94,14 @@ class StocksUpdater:
|
||||
logging.info(
|
||||
f"Successfully uploaded {len(updates)} updates to {marketplace.name} in {round(time.time() - start, 2)} seconds.")
|
||||
|
||||
async def update_marketplace_products(self, marketplace_id: int, product_ids: list[int]):
|
||||
marketplace = await self.get_marketplace(marketplace_id)
|
||||
start = time.time()
|
||||
updater = UpdaterFactory.get_updater(self.session, marketplace)
|
||||
await updater.update_products(product_ids)
|
||||
logging.info(
|
||||
f"Successfully updated {len(product_ids)} products for {marketplace.name} in {round(time.time() - start, 2)} seconds.")
|
||||
|
||||
async def update(self, updates: list[StockUpdate]):
|
||||
updates_dict = defaultdict(list)
|
||||
for update in updates:
|
||||
|
||||
Reference in New Issue
Block a user