feat(report):add design_progress_status_state
This commit is contained in:
@@ -5,6 +5,7 @@ from uuid import UUID
|
||||
|
||||
from fastapi import HTTPException
|
||||
|
||||
from app.config import TaskEnv
|
||||
from app.models.design_progress import DesignProgressModel, CreateDesignProgress, RecordModel, GetRecord, \
|
||||
UpdateDesignProgress
|
||||
from core.repositories.base import BaseRepository
|
||||
@@ -24,11 +25,13 @@ class DesignProgressRepository(BaseRepository):
|
||||
"sub_type": _inp.sub_type
|
||||
})
|
||||
if not exist:
|
||||
project = await use_collection(TaskEnv.CLN_PROJECT).find_one({"_id":_inp.project_id})
|
||||
progress = DesignProgressModel(
|
||||
project_id=_inp.project_id,
|
||||
type=_inp.type,
|
||||
parent_id=_inp.parent_id,
|
||||
sub_type=_inp.sub_type,
|
||||
state = project['design']['state']
|
||||
)
|
||||
progress.init_id().cu_at()
|
||||
await use_collection(COLLECTION).insert_one(progress.mongo_dict())
|
||||
|
||||
@@ -421,4 +421,16 @@ class ReportRepository():
|
||||
]).to_list(None)
|
||||
return result
|
||||
|
||||
async def design_progress_status_state(self):
|
||||
result = await use_collection("design_progress").aggregate([
|
||||
{'$match':{'complete_at':{"$exists":0},'parent_id':{"$exists":0}}},
|
||||
{"$group":
|
||||
{'_id': {'state':"$state",'type':'$type'},
|
||||
'count': {'$sum': 1},
|
||||
"projectIds": {"$addToSet": "$project_id"},
|
||||
},
|
||||
}
|
||||
]).to_list(None)
|
||||
return result
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user