feat(report):add progress_phisical and progress_phisica/avg
This commit is contained in:
@@ -323,4 +323,74 @@ class ReportRepository():
|
|||||||
result['bet_100_200'].append(_model.project_id)
|
result['bet_100_200'].append(_model.project_id)
|
||||||
else:
|
else:
|
||||||
result['upper_than_200'].append(_model.project_id)
|
result['upper_than_200'].append(_model.project_id)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
async def progress_report(self):
|
||||||
|
result = await use_collection(TaskEnv.CLN_MONITOR_PYSICAL).aggregate([
|
||||||
|
{
|
||||||
|
"$sort": {'date_at': -1}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'$group':
|
||||||
|
{
|
||||||
|
'_id': "$project_id",
|
||||||
|
'records': {"$push": "$$ROOT"},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$project": {
|
||||||
|
"_id": 1,
|
||||||
|
"records": {"$slice": ["$records", 1]},
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]).to_list(None)
|
||||||
|
result_report = {
|
||||||
|
'less_than_1':[],
|
||||||
|
'bet_1_2':[],
|
||||||
|
'bet_2_5':[],
|
||||||
|
'upper_than_5':[],
|
||||||
|
}
|
||||||
|
|
||||||
|
for i in result:
|
||||||
|
print(i['records'])
|
||||||
|
if ('records' in i) and (len(i['records'])>0) and 'last_month' in i['records'][0]:
|
||||||
|
cal = i['records'][0]['last_month']
|
||||||
|
if cal < 1:
|
||||||
|
result_report['less_than_1'].append(i["_id"])
|
||||||
|
elif cal <= 2:
|
||||||
|
result_report['bet_1_2'].append(i["_id"])
|
||||||
|
elif cal <= 5:
|
||||||
|
result_report['bet_2_5'].append(i["_id"])
|
||||||
|
else:
|
||||||
|
result_report['upper_than_5'].append(i["_id"])
|
||||||
|
return result_report
|
||||||
|
|
||||||
|
async def progress_avg_report(self):
|
||||||
|
result = await use_collection(TaskEnv.CLN_MONITOR_PYSICAL).aggregate([
|
||||||
|
{
|
||||||
|
'$group':
|
||||||
|
{
|
||||||
|
'_id': "$project_id",
|
||||||
|
'avg':{'$avg': "$real"},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
]).to_list(None)
|
||||||
|
result_report = {
|
||||||
|
'less_than_1':[],
|
||||||
|
'bet_1_2':[],
|
||||||
|
'bet_2_5':[],
|
||||||
|
'upper_than_5':[],
|
||||||
|
}
|
||||||
|
|
||||||
|
for i in result:
|
||||||
|
if i['avg'] < 1:
|
||||||
|
result_report['less_than_1'].append(i["_id"])
|
||||||
|
elif i['avg'] <= 2:
|
||||||
|
result_report['bet_1_2'].append(i["_id"])
|
||||||
|
elif i['avg'] <= 5:
|
||||||
|
result_report['bet_2_5'].append(i["_id"])
|
||||||
|
else:
|
||||||
|
result_report['upper_than_5'].append(i["_id"])
|
||||||
|
return result_report
|
||||||
|
|||||||
@@ -89,6 +89,17 @@ def delay_donut(project_id:uuid.UUID):
|
|||||||
@shrink(repo.add_cost)
|
@shrink(repo.add_cost)
|
||||||
def add_cost():
|
def add_cost():
|
||||||
pass
|
pass
|
||||||
|
# تفکیک درصد پیشرفت ماهیانه پروژه ها
|
||||||
|
@router.get('/progress_phisical', tags=_tag_base)
|
||||||
|
@shrink(repo.progress_report)
|
||||||
|
def progress_report():
|
||||||
|
pass
|
||||||
|
|
||||||
|
# تفکیک درصد پیشرفت میانگین ماهیانه پروژه ها
|
||||||
|
@router.get('/progress_phisica/avg', tags=_tag_base)
|
||||||
|
@shrink(repo.progress_avg_report)
|
||||||
|
def progress_avg_report():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user