Merge pull request 'added optional mongo client for already configured monitors' (#15) from development into main
Reviewed-on: #15
This commit was merged in pull request #15.
This commit is contained in:
commit
87d751cd82
1 file changed
+8
-2
@@ -29,17 +29,23 @@ NO_MSRP_PRIORITY = 6
|
||||
NEW_LISTING_PRIORITY = 6
|
||||
|
||||
|
||||
def get_collection(collection_name: str) -> AsyncIOMotorCollection:
|
||||
def get_collection(
|
||||
collection_name: str, mongo_client: AsyncIOMotorClient = None
|
||||
) -> AsyncIOMotorCollection:
|
||||
"""Return the named collection from the shared client's database.
|
||||
|
||||
Args:
|
||||
collection_name: Name of the collection to return.
|
||||
mongo_client: optional client for projects with already configured client
|
||||
|
||||
Returns:
|
||||
The requested collection.
|
||||
"""
|
||||
|
||||
return get_mongo_client()[MONGO_DATABASE_NAME][collection_name]
|
||||
if mongo_client is None:
|
||||
mongo_client = get_mongo_client()
|
||||
|
||||
return mongo_client[MONGO_DATABASE_NAME][collection_name]
|
||||
|
||||
|
||||
def resolve_alerts_collection(
|
||||
|
||||
Reference in new issue
Block a user