feat(report):add design_progress_status
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user