fix: add missing await in MongoDB get_all_status_counts aggregation

Resolves 'coroutine' object has no attribute 'to_list' error in document pagination endpoint by adding missing await keyword before self._data.aggregate() call.
This commit is contained in:
yangdx 2025-07-31 02:27:16 +08:00
parent 2af8a93dc7
commit 41de51a4db

View file

@ -366,7 +366,7 @@ class MongoDocStatusStorage(DocStatusStorage):
async def get_status_counts(self) -> dict[str, int]:
"""Get counts of documents in each status"""
pipeline = [{"$group": {"_id": "$status", "count": {"$sum": 1}}}]
cursor = self._data.aggregate(pipeline, allowDiskUse=True)
cursor = await self._data.aggregate(pipeline, allowDiskUse=True)
result = await cursor.to_list()
counts = {}
for doc in result:
@ -620,7 +620,7 @@ class MongoDocStatusStorage(DocStatusStorage):
Dictionary mapping status names to counts, including 'all' field
"""
pipeline = [{"$group": {"_id": "$status", "count": {"$sum": 1}}}]
cursor = self._data.aggregate(pipeline, allowDiskUse=True)
cursor = await self._data.aggregate(pipeline, allowDiskUse=True)
result = await cursor.to_list()
counts = {}