feat(progress physical):add avg
This commit is contained in:
@@ -40,12 +40,12 @@ class PhysicalProgressRepository(BaseRepository):
|
|||||||
send['three_month'] = three_month
|
send['three_month'] = three_month
|
||||||
_avg = await use_collection(TaskEnv.CLN_MONITOR_PYSICAL).aggregate([
|
_avg = await use_collection(TaskEnv.CLN_MONITOR_PYSICAL).aggregate([
|
||||||
{'$match':{'project_id':_inp.project_id}},
|
{'$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)
|
]).to_list(None)
|
||||||
if _avg:
|
if _avg:
|
||||||
send['avg'] = _avg[0]['avg']
|
send['avg'] = _avg[0]
|
||||||
else:
|
else:
|
||||||
send['avg'] = None
|
send['avg'] = {}
|
||||||
return send
|
return send
|
||||||
|
|
||||||
async def create(self, _inp: MODEL):
|
async def create(self, _inp: MODEL):
|
||||||
|
|||||||
Reference in New Issue
Block a user