feat(report):change report sts

This commit is contained in:
shahzeydyfah
2025-01-16 00:00:00 +03:30
parent 79d542381d
commit 6dcde300b1
3 changed files with 23 additions and 11 deletions
+1
View File
@@ -8,6 +8,7 @@ class StatusReport(pydantic.BaseModel):
state: Optional[str]
type_id: Optional[int] = Field(description='کد شناسایی نوع پروژه در این فیلد قرار می گیرد')
nature_id: Optional[int] = Field(description='کد شناسایی ماهبت در این فیلد قرار می گیرد')
monitor_type: Optional[int]
class ReportCountry(pydantic.BaseModel):
type_id: int = Field(description='کد شناسایی نوع پروژه در این فیلد قرار می گیرد')
+19 -9
View File
@@ -15,6 +15,8 @@ class ReportRepository():
match.update({'design.type_id': _inp.type_id})
if _inp.nature_id:
match.update({'design.nature_id': _inp.nature_id})
if type == 'monitor' and _inp.monitor_type:
match.update({'monitor.base_information.type': _inp.monitor_type})
report = await use_collection(TaskEnv.CLN_PROJECT).aggregate([
{
"$match": match
@@ -66,16 +68,24 @@ class ReportRepository():
# return {'count_nature':count_nature,'count_type':count_type,'count_monitor_type':count_monitor_type}
return report
async def exist_project_state(self):
report = await use_collection(TaskEnv.CLN_PROJECT).aggregate([
{
'$group': {
'_id': "$design.state",
'count': {'$sum': 1}
}
async def exist_project_state(self,_inp: StatusReport):
match ={}
aggregate = []
if _inp.type_id:
match.update({'design.type_id': _inp.type_id})
if _inp.nature_id:
match.update({'design.nature_id': _inp.nature_id})
if _inp.monitor_type:
match.update({'monitor.base_information.type': _inp.monitor_type})
if match:
aggregate.append({"$match": match})
aggregate.append({
'$group': {
'_id': "$design.state",
'count': {'$sum': 1}
}
]).to_list(None)
})
report = await use_collection(TaskEnv.CLN_PROJECT).aggregate(aggregate).to_list(None)
return report
async def donut(self, _select: int):
+3 -2
View File
@@ -25,9 +25,10 @@ def project_status_monitor(_inp: StatusReport):
def report_country(_inp: ReportCountry):
pass
@router.get('/exist_state', tags=_tag_base)
# نمایش تعداد پروژه ها در هر شهر بر اساس فیلترهای انتخاب شده
@router.post('/exist_state', tags=_tag_base)
@shrink(repo.exist_project_state)
def exist_project_state():
def exist_project_state(_inp: StatusReport):
pass
@router.get('/donut/delay', tags=_tag_base)