diff --git a/app/repositories/report.py b/app/repositories/report.py index 690208c..8fdcb98 100644 --- a/app/repositories/report.py +++ b/app/repositories/report.py @@ -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 \ No newline at end of file diff --git a/app/urls/report.py b/app/urls/report.py index 36ab6ea..3ca909c 100644 --- a/app/urls/report.py +++ b/app/urls/report.py @@ -23,4 +23,9 @@ def project_status_monitor(_inp: StatusReport): def report_country(_inp: ReportCountry): pass +@router.get('/exist_state', tags=_tag_base) +@shrink(repo.exist_project_state) +def exist_project_state(): + pass + app.include_router(router) \ No newline at end of file