From b08d2f6f4e9f732214495a66dff629a3cf4c538f Mon Sep 17 00:00:00 2001 From: shahzeydyfah Date: Thu, 23 Jan 2025 23:20:42 +0330 Subject: [PATCH] feat(report):add design_progress_status --- app/models/report.py | 7 ++++++- app/repositories/report.py | 30 +++++++++++++++++++++++++++++- app/urls/report.py | 13 +++++++++++-- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/app/models/report.py b/app/models/report.py index bc7e92f..f9b5972 100644 --- a/app/models/report.py +++ b/app/models/report.py @@ -1,3 +1,4 @@ +import datetime import uuid from typing import Optional, Literal @@ -23,4 +24,8 @@ class DelayDonutDetail(pydantic.BaseModel): class DonutList(pydantic.BaseModel): type: int = Field(description='مقدار وارد شده در گزارش قبل') - donut_select: str = Field(description='آیتم دونات انتخاب شده') \ No newline at end of file + donut_select: str = Field(description='آیتم دونات انتخاب شده') + +class PhysicalMonth(pydantic.BaseModel): + from_date:datetime.datetime + to_date:datetime.datetime \ No newline at end of file diff --git a/app/repositories/report.py b/app/repositories/report.py index 7bd8d2b..5246256 100644 --- a/app/repositories/report.py +++ b/app/repositories/report.py @@ -1,8 +1,9 @@ import uuid +from datetime import time from app.config import TaskEnv from app.models.project import ProjectPriceReport -from app.models.report import StatusReport, ReportCountry, DonutList, DelayDonutDetail +from app.models.report import StatusReport, ReportCountry, DonutList, DelayDonutDetail, PhysicalMonth from core.service.mongo_db import use_collection @@ -394,3 +395,30 @@ class ReportRepository(): else: result_report['upper_than_5'].append(i["_id"]) return result_report + + async def progress_month_report(self,_inp:PhysicalMonth): + from datetime import datetime, time + to_date = datetime.combine(_inp.to_date.date(), time.max) + from_date = _inp.from_date.combine(_inp.from_date.date(), time.min) + result = await use_collection(TaskEnv.CLN_MONITOR_PYSICAL).aggregate([ + {"$match":{"date_at":{"$lte":to_date,"$gte":from_date}}}, + {"$group": + {'_id': {"year": "$year", "month": "$month"}, + 'avg': {'$avg': "$real"}}, + } + ]).to_list(None) + return result + + async def design_progress_status(self): + result = await use_collection("design_progress").aggregate([ + {'$match':{'complete_at':{"$exists":0},'parent_id':{"$exists":0}}}, + {"$group": + {'_id': '$type', + 'count': {'$sum': 1}, + "projectIds": {"$addToSet": "$project_id"}, + }, + } + ]).to_list(None) + return result + + diff --git a/app/urls/report.py b/app/urls/report.py index d872931..1864887 100644 --- a/app/urls/report.py +++ b/app/urls/report.py @@ -2,7 +2,7 @@ import uuid from fastapi import Body -from app.models.report import StatusReport, ReportCountry, DonutList, DelayDonutDetail +from app.models.report import StatusReport, ReportCountry, DonutList, DelayDonutDetail, PhysicalMonth from app.repositories.report import ReportRepository from core.app import app from core.utils.router import generate_router, shrink @@ -101,6 +101,15 @@ def progress_report(): def progress_avg_report(): pass - +# میانگین پیشرفت ماهیانه پروژه ها نمودار میله ای-بدون وزن +@router.post('/progress_phisica/avg/month', tags=_tag_base) +@shrink(repo.progress_month_report) +def progress_month_report(_inp:PhysicalMonth = Body(...)): + pass +# وضعیت پروژه های در دست طراحی +@router.get('/design_progress/status', tags=_tag_base) +@shrink(repo.design_progress_status) +def design_progress_status(): + pass app.include_router(router) \ No newline at end of file