feat:add exist project by state

This commit is contained in:
shahzeydyfah
2024-09-21 13:16:33 +03:30
parent 031146ff2a
commit 481de32c09
2 changed files with 21 additions and 0 deletions
+16
View File
@@ -1,3 +1,5 @@
import uuid
from app.config import TaskEnv
from app.models.report import StatusReport, ReportCountry
from core.service.mongo_db import use_collection
@@ -42,3 +44,17 @@ class ReportRepository():
count_type = await use_collection(TaskEnv.CLN_PROJECT).count_documents({'design.type_id':_inp.type_id})
count_monitor_type = await use_collection(TaskEnv.CLN_PROJECT).count_documents({'monitor.base_information.type': _inp.monitor_type})
return {'count_nature':count_nature,'count_type':count_type,'count_monitor_type':count_monitor_type}
async def exist_project_state(self):
report = await use_collection(TaskEnv.CLN_PROJECT).aggregate([
{
},
{
'$group': {
'_id': f"design.state",
'count': {'$sum': 1}
}
}
]).to_list(None)
return report