From 59bb37d49404a2a9ed539c77463b046e3c53af0c Mon Sep 17 00:00:00 2001 From: shahzeydyfah Date: Thu, 31 Oct 2024 11:28:54 +0330 Subject: [PATCH] feat(progress physical):add avg --- app/repositories/monitor_physical_progress.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/repositories/monitor_physical_progress.py b/app/repositories/monitor_physical_progress.py index a2feb41..d565f35 100644 --- a/app/repositories/monitor_physical_progress.py +++ b/app/repositories/monitor_physical_progress.py @@ -38,6 +38,14 @@ class PhysicalProgressRepository(BaseRepository): three_month = await self.search_last(TaskEnv.CLN_MONITOR_PYSICAL, _inp, 95, 85) if three_month: 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"}}} + ]).to_list(None) + if _avg: + send['avg'] = _avg[0]['avg'] + else: + send['avg'] = None return send async def create(self, _inp: MODEL):