moved discord specifics into discord bot repo
This commit is contained in:
1 parent
44f8184864
commit
bd46b92724
3 files changed
+6
-35
No files matched your search
@@ -15,11 +15,7 @@ from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorCollection
|
||||
from pymongo import UpdateOne
|
||||
from pymongo.errors import BulkWriteError, PyMongoError
|
||||
|
||||
from monitor_utils.constants import (
|
||||
ALERTS_COLLECTION_NAME,
|
||||
MONGO_DATABASE_NAME,
|
||||
MONGO_URL,
|
||||
)
|
||||
from monitor_utils.constants import MONGO_DATABASE_NAME, MONGO_URL
|
||||
from monitor_utils.models import Product
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
@@ -145,7 +141,9 @@ async def add_products_to_database(
|
||||
raise
|
||||
|
||||
|
||||
async def write_alert_ops(alert_ops: list[UpdateOne]):
|
||||
async def write_alert_ops(
|
||||
alert_ops: list[UpdateOne], alerts_collection_name: AsyncIOMotorCollection
|
||||
):
|
||||
"""Write alert upserts, swallowing duplicate-key races.
|
||||
|
||||
Concurrent tasks upserting an alert for the same product can both pass
|
||||
@@ -159,7 +157,7 @@ async def write_alert_ops(alert_ops: list[UpdateOne]):
|
||||
"""
|
||||
|
||||
try:
|
||||
await get_collection(ALERTS_COLLECTION_NAME).bulk_write(
|
||||
await get_collection(alerts_collection_name).bulk_write(
|
||||
alert_ops, ordered=False
|
||||
)
|
||||
except BulkWriteError as exc:
|
||||
|
||||
Reference in new issue
Block a user