@@ -234,7 +234,8 @@ async def get_event_statistics(
234234 ]
235235 )
236236
237- result = await self ._collection .aggregate (pipeline ).to_list (length = 1 )
237+ cursor = await self ._collection .aggregate (pipeline )
238+ result = await cursor .to_list (length = 1 )
238239
239240 if result :
240241 stats = result [0 ]
@@ -296,7 +297,8 @@ async def get_event_statistics_filtered(
296297 ]
297298 )
298299
299- result = await self ._collection .aggregate (pipeline ).to_list (length = 1 )
300+ cursor = await self ._collection .aggregate (pipeline )
301+ result = await cursor .to_list (length = 1 )
300302 if result :
301303 stats = result [0 ]
302304 return EventStatistics (
@@ -321,7 +323,9 @@ async def stream_events(
321323 if filters :
322324 pipeline .append ({"$match" : filters })
323325
324- async with self ._collection .watch (pipeline , start_after = start_after , full_document = "updateLookup" ) as stream :
326+ async with await self ._collection .watch (
327+ pipeline , start_after = start_after , full_document = "updateLookup"
328+ ) as stream :
325329 async for change in stream :
326330 if change ["operationType" ] in ["insert" , "update" , "replace" ]:
327331 yield change ["fullDocument" ]
@@ -438,7 +442,7 @@ async def aggregate_events(self, pipeline: list[dict[str, object]], limit: int =
438442 pipeline .append ({"$limit" : limit })
439443
440444 results = []
441- async for doc in self ._collection .aggregate (pipeline ):
445+ async for doc in await self ._collection .aggregate (pipeline ):
442446 if "_id" in doc and isinstance (doc ["_id" ], dict ):
443447 doc ["_id" ] = str (doc ["_id" ])
444448 results .append (doc )
@@ -451,7 +455,7 @@ async def list_event_types(self, match: Mapping[str, object] = MappingProxyType(
451455 pipeline .append ({"$match" : dict (match )})
452456 pipeline .extend ([{"$group" : {"_id" : f"${ EventFields .EVENT_TYPE } " }}, {"$sort" : {"_id" : 1 }}])
453457 event_types : list [str ] = []
454- async for doc in self ._collection .aggregate (pipeline ):
458+ async for doc in await self ._collection .aggregate (pipeline ):
455459 event_types .append (doc ["_id" ])
456460 return event_types
457461
0 commit comments