mix fix
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from redis import asyncio as aioredis
|
from redis import asyncio as aioredis
|
||||||
@@ -51,7 +52,7 @@ class BatchLimiter:
|
|||||||
await redis.set(key, 1)
|
await redis.set(key, 1)
|
||||||
await redis.set(f"{key}:start_time", datetime.now().isoformat())
|
await redis.set(f"{key}:start_time", datetime.now().isoformat())
|
||||||
except aioredis.RedisError as e:
|
except aioredis.RedisError as e:
|
||||||
print(f"Redis error: {e}")
|
logging.error(f"Redis error: {e}")
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
async def acquire_wildberries(self, key):
|
async def acquire_wildberries(self, key):
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ async def get_stocks_data(
|
|||||||
),
|
),
|
||||||
else_=0)
|
else_=0)
|
||||||
.label('warehouse_stock'),
|
.label('warehouse_stock'),
|
||||||
func.coalesce(mix_stock_full_subquery.c.mix_stock, 0).label('mix_stock'),
|
mix_stock_full_subquery.c.mix_stock.label('mix_stock'),
|
||||||
func.coalesce(in_block_subquery.c.in_block_value, 1).label('in_block_value'),
|
func.coalesce(in_block_subquery.c.in_block_value, 1).label('in_block_value'),
|
||||||
is_master_subquery.c.is_master.label('is_master'),
|
is_master_subquery.c.is_master.label('is_master'),
|
||||||
func.coalesce(slaves_stock_subquery.c.slaves_stock, 0).label('slaves_stock'),
|
func.coalesce(slaves_stock_subquery.c.slaves_stock, 0).label('slaves_stock'),
|
||||||
@@ -313,6 +313,10 @@ async def get_stocks_data(
|
|||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
is_mix = mix_stock is not None
|
is_mix = mix_stock is not None
|
||||||
|
|
||||||
|
if not mix_stock:
|
||||||
|
mix_stock = 0
|
||||||
|
|
||||||
if all([is_mix, slaves_stock > 0]):
|
if all([is_mix, slaves_stock > 0]):
|
||||||
mix_stock = 0
|
mix_stock = 0
|
||||||
balance_limit = price_purchase > company.balance
|
balance_limit = price_purchase > company.balance
|
||||||
@@ -338,5 +342,4 @@ async def get_stocks_data(
|
|||||||
'full_stock': full_stock,
|
'full_stock': full_stock,
|
||||||
'marketplace_product': marketplace_product,
|
'marketplace_product': marketplace_product,
|
||||||
})
|
})
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|||||||
Reference in New Issue
Block a user