fix(report):order progress_month_report
This commit is contained in:
@@ -139,6 +139,34 @@ class PhysicalProgressRepository(BaseRepository):
|
||||
else:
|
||||
await use_collection(COLLECTION).update_one({"_id": _i_model.id},{"$set": _update})
|
||||
return True
|
||||
# for recalc medium progress in database
|
||||
# async def recalc_medium_progress(self):
|
||||
# print('111111111111111111111')
|
||||
# coll = use_collection(TaskEnv.CLN_MONITOR_PYSICAL)
|
||||
# project_ids = await coll.distinct(
|
||||
# "project_id",
|
||||
# {"deleted_at": {"$exists": False}},
|
||||
# )
|
||||
# print('222222222222222222222')
|
||||
#
|
||||
# updated = 0
|
||||
# for pid in project_ids:
|
||||
# print('piiiiiidf',pid)
|
||||
# records = await coll.find({
|
||||
# "project_id": pid,
|
||||
# "deleted_at": {"$exists": False},
|
||||
# }).sort([("date_at", 1), ("_id", 1)]).to_list(None)
|
||||
#
|
||||
# total = 0
|
||||
# for i, rec in enumerate(records, start=1):
|
||||
# total += rec.get("real") or 0
|
||||
# await coll.update_one(
|
||||
# {"_id": rec["_id"]},
|
||||
# {"$set": {"medium_progress": round(total / i, 1)}},
|
||||
# )
|
||||
# updated += 1
|
||||
#
|
||||
# return {"projects": len(project_ids), "updated": updated}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ from core.service.mongo_db import use_collection
|
||||
class ReportRepository():
|
||||
async def project_status(self, _inp: StatusReport, type):
|
||||
if _inp.state:
|
||||
match = {f'{type}.sts': {'$exists': 1}, 'design.state': _inp.state}
|
||||
match = {f'{type}.sts': {'$exists': 1}, 'design.state': _inp.state,'sts':1}
|
||||
else:
|
||||
match = {f'{type}.sts': {'$exists': 1}}
|
||||
match = {f'{type}.sts': {'$exists': 1},'sts':1}
|
||||
if _inp.type_id:
|
||||
match.update({'design.type_id': _inp.type_id})
|
||||
if _inp.nature_id:
|
||||
|
||||
@@ -25,6 +25,11 @@ def create(coding: ThisModel = Body(...)):
|
||||
def last_record(last:LastRecord):
|
||||
pass
|
||||
|
||||
# @router.get('/progress/rediv', response_model=list[dict], tags=_tag_base, description='پیشرفت فیزیکی')
|
||||
# @shrink(repo.recalc_medium_progress)
|
||||
# def recalc_medium_progress():
|
||||
# pass
|
||||
|
||||
@router.get('/list/{_id}', response_model=List[ThisModel], tags=_tag_base, description='پیشرفت فیزیکی')
|
||||
@shrink(repo.list_by_project)
|
||||
def list_by_project(_id: UUID):
|
||||
|
||||
Reference in New Issue
Block a user