diff --git a/database/sipro/models/general.py b/database/sipro/models/general.py index 15e90de..b5e6f22 100644 --- a/database/sipro/models/general.py +++ b/database/sipro/models/general.py @@ -54,6 +54,7 @@ class Marketplace(BaseSiproModel): sell_from_price: Mapped[bool] = mapped_column() is_deleted: Mapped[bool] = mapped_column() is_paused: Mapped[bool] = mapped_column() + send_stocks: Mapped[bool] = mapped_column() warehouses: Mapped[List["Warehouse"]] = relationship(secondary=marketplace_warehouses) warehouse_id: Mapped[str] = mapped_column() diff --git a/updaters/stocks_updater.py b/updaters/stocks_updater.py index 1b8a166..b5cdaa7 100644 --- a/updaters/stocks_updater.py +++ b/updaters/stocks_updater.py @@ -47,6 +47,7 @@ class StocksUpdater: Company.is_archived == False, Marketplace.is_deleted == False, Marketplace.is_paused == False, + Marketplace.send_stocks==True, Marketplace.base_marketplace.in_([ BaseMarketplace.OZON, BaseMarketplace.WILDBERRIES, @@ -63,6 +64,8 @@ class StocksUpdater: async def full_update_marketplace(self, marketplace_id: int): marketplace = await self.get_marketplace(marketplace_id) + if not marketplace.send_stocks: + return start = time.time() updater = UpdaterFactory.get_updater(self.session, marketplace) await updater.update_all() @@ -97,6 +100,8 @@ class StocksUpdater: async def update_marketplace_products(self, marketplace_id: int, product_ids: list[int]): marketplace = await self.get_marketplace(marketplace_id) + if not marketplace.send_stocks: + return start = time.time() updater = UpdaterFactory.get_updater(self.session, marketplace) await updater.update_products(product_ids) @@ -118,6 +123,7 @@ class StocksUpdater: Company.is_deleted == False, Company.is_archived == False, Marketplace.is_paused == False, + Marketplace.send_stocks == True ) ) stmt_result = await self.session.execute(stmt) @@ -133,10 +139,10 @@ class StocksUpdater: tasks.append(self.update_marketplace(marketplace_id, marketplace_updates)) await asyncio.gather(*tasks) - async def reset_marketplace(self, marketplace_id:int): + async def reset_marketplace(self, marketplace_id: int): marketplace = await self.get_marketplace(marketplace_id) start = time.time() - updater = UpdaterFactory.get_updater(self.session,marketplace) + updater = UpdaterFactory.get_updater(self.session, marketplace) await updater.reset() logging.info( f"{marketplace.name} successfully updated in {round(time.time() - start, 2)} seconds.")