feat(report):add /donut/add/time

This commit is contained in:
shahzeydyfah
2025-01-16 21:50:07 +03:30
parent 7dcae49b4b
commit b5e93ab4e8
2 changed files with 56 additions and 16 deletions
+36 -7
View File
@@ -215,6 +215,35 @@ class ReportRepository():
i["title"] = _obj[str(i["_id"])]
return report
async def categorize_deviation(self):
report = await use_collection(TaskEnv.CLN_MONITOR_PYSICAL).aggregate(
[{"$match": {"deviation": {"$exists": True, "$ne": None}}},
{"$group": {
"_id": {
"$cond": [
{"$lt": ["$deviation", 10]},
"less_than_10",
{
"$cond": [
{"$and": [{"$gte": ["$deviation", 10]}, {"$lt": ["$deviation", 25]}]},
"between_10_and_25",
{
"$cond": [
{"$and": [{"$gte": ["$deviation", 25]},
{"$lt": ["$deviation", 40]}]},
"between_25_and_40",
"greater_than_40"
]
}
]
}
]
},
"count": {"$sum": 1},
"projectIds": { "$addToSet": "$project_id" },
"totalDeviation": {"$sum": "$deviation"}, }}]).to_list(None)
return report
async def list_delay_donut(self, _select: str):
get_list = []
_map = {'1': 'financial.total', '2': 'force_major.total', '3': 'technical.total', '4': 'extra_new_work',
@@ -229,7 +258,7 @@ class ReportRepository():
# projects = await use_collection(TaskEnv.CLN_PROJECT).find({"_id":{"$in":get_list}}).to_list(None)
return get_list
async def sum_delay_percent(self):
async def sum_add_time_end_project(self):
result = {}
result['less_than_20'] = []
result['bet_20_50']= []
@@ -245,16 +274,16 @@ class ReportRepository():
list_project = await use_collection(TaskEnv.CLN_PROJECT).find({"_id":{"$in":get_list_project_id}}).to_list(None)
if list_project:
for i in list_project:
if i['monitor']['detail']['first_time']:
if i['monitor']['detail']['first_time'] and i['monitor']['sts'] == 5:
cal = (get_dict_project_id[str(i["_id"])]['sum']/i['monitor']['detail']['first_time'])*100
if cal < 20 :
result['less_than_20'].append(i)
result['less_than_20'].append(i["_id"])
elif cal < 50:
result['bet_20_50'].append(i)
result['bet_20_50'].append(i["_id"])
elif cal < 100:
result['bet_50_100'].append(i)
result['bet_50_100'].append(i["_id"])
elif cal < 200:
result['bet_100_200'].append(i)
result['bet_100_200'].append(i["_id"])
else:
result['upper_than_200'].append(i)
result['upper_than_200'].append(i["_id"])
return result