rewritten crap

This commit is contained in:
2025-05-11 08:00:23 +03:00
parent b5110ec69a
commit 2e3245c8f9
8 changed files with 72 additions and 60 deletions

View File

@@ -73,6 +73,7 @@ class BaseMarketplaceUpdater(ABC):
return {}
async def filter_stocks_data(self, stock_data_list: list[StockData]) -> list[StockData]:
return stock_data_list
cached_stocks: dict = await self.redis_client.hgetall(self.get_cache_key())
cached_stocks = {int(k): int(v) for k, v in cached_stocks.items()}
result = []
@@ -86,6 +87,8 @@ class BaseMarketplaceUpdater(ABC):
async def after_sender_sent(self, stock_requests: list[StockRequest], invalid_product_ids: list[int]):
stock_requests = list(filter(lambda stock: stock['product_id'] not in invalid_product_ids, stock_requests))
mapping = {stock['product_id']: stock['full_stock'] for stock in stock_requests}
if not mapping:
return
await self.redis_client.hset(self.get_cache_key(), mapping=mapping)
async def get_marketplace_updates(self, stock_data_list: list[StockData]) -> list[StockRequest]: