added keyword args instead of postional for execute monitor logic
This commit is contained in:
1 parent
8f86e85c50
commit
6025393ad4
2 files changed
+9
-5
No files matched your search
@@ -60,12 +60,11 @@ async def add_products_to_database(
|
|||||||
new_price is not None and new_price < old_price
|
new_price is not None and new_price < old_price
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set_on_insert = {"discoveredDate": datetime.now(timezone.utc)}
|
||||||
if price_dropped:
|
if price_dropped:
|
||||||
document["status"] = STATUS_PENDING
|
document["status"] = STATUS_PENDING
|
||||||
document["priceBeforeDrop"] = old_price
|
document["priceBeforeDrop"] = old_price
|
||||||
|
else:
|
||||||
set_on_insert = {"discoveredDate": datetime.now(timezone.utc)}
|
|
||||||
if not price_dropped:
|
|
||||||
set_on_insert["status"] = STATUS_PENDING
|
set_on_insert["status"] = STATUS_PENDING
|
||||||
|
|
||||||
ops.append(
|
ops.append(
|
||||||
@@ -79,7 +78,10 @@ async def add_products_to_database(
|
|||||||
try:
|
try:
|
||||||
await collection.bulk_write(ops, ordered=False)
|
await collection.bulk_write(ops, ordered=False)
|
||||||
except PyMongoError:
|
except PyMongoError:
|
||||||
LOGGER.exception(f"{category_identifier} - failed to add products to database")
|
LOGGER.exception(
|
||||||
|
"failed to add products to database",
|
||||||
|
extra={"category": category_identifier},
|
||||||
|
)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -135,9 +135,10 @@ def build_product_details(
|
|||||||
|
|
||||||
|
|
||||||
async def execute_monitor_logic(
|
async def execute_monitor_logic(
|
||||||
proxies: AioProxies,
|
|
||||||
category_identifiers: list[str] | dict[str, str],
|
category_identifiers: list[str] | dict[str, str],
|
||||||
task_func: Callable[..., Awaitable[None]],
|
task_func: Callable[..., Awaitable[None]],
|
||||||
|
*,
|
||||||
|
proxies: AioProxies,
|
||||||
headers: dict | None = None,
|
headers: dict | None = None,
|
||||||
cookies: dict | None = None,
|
cookies: dict | None = None,
|
||||||
pre_task_func: Callable[..., Awaitable[None]] | None = None,
|
pre_task_func: Callable[..., Awaitable[None]] | None = None,
|
||||||
@@ -203,6 +204,7 @@ async def execute_pagination(
|
|||||||
products_per_page: int,
|
products_per_page: int,
|
||||||
func: Callable[..., Awaitable[None]],
|
func: Callable[..., Awaitable[None]],
|
||||||
session: aiohttp.ClientSession | AsyncSession,
|
session: aiohttp.ClientSession | AsyncSession,
|
||||||
|
*,
|
||||||
max_concurrent_tasks: int = 5,
|
max_concurrent_tasks: int = 5,
|
||||||
start_offset: int = 24,
|
start_offset: int = 24,
|
||||||
pagination_mode: str = "offset",
|
pagination_mode: str = "offset",
|
||||||
|
|||||||
Reference in new issue
Block a user