From 5123d434ece2753e80682d744e2dab51f7f5a5d3 Mon Sep 17 00:00:00 2001 From: shahzeydyfah Date: Thu, 31 Oct 2024 11:35:25 +0330 Subject: [PATCH] feat(progress physical):add avg --- app/repositories/monitor_physical_progress.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/repositories/monitor_physical_progress.py b/app/repositories/monitor_physical_progress.py index d565f35..8e99e04 100644 --- a/app/repositories/monitor_physical_progress.py +++ b/app/repositories/monitor_physical_progress.py @@ -40,12 +40,12 @@ class PhysicalProgressRepository(BaseRepository): send['three_month'] = three_month _avg = await use_collection(TaskEnv.CLN_MONITOR_PYSICAL).aggregate([ {'$match':{'project_id':_inp.project_id}}, - {'$group': {'_id': None, 'avg': {'$avg': "$real"}}} + {'$group': {'_id': None, 'avg': {'$avg': "$real"}, 'sum':{'$sum': "$real"}, 'count':{'$sum': 1}}} ]).to_list(None) if _avg: - send['avg'] = _avg[0]['avg'] + send['avg'] = _avg[0] else: - send['avg'] = None + send['avg'] = {} return send async def create(self, _inp: MODEL):