fix:design progress
This commit is contained in:
@@ -49,11 +49,19 @@ class DesignProgressRepository(BaseRepository[CreateDesignProgress]):
|
||||
return progress
|
||||
|
||||
async def update(self, _id: UUID, _inp: UpdateDesignProgress):
|
||||
start_at = None
|
||||
design_progress = await use_collection(COLLECTION).find_one({"_id": _id})
|
||||
design_progress = DesignProgressModel(**design_progress)
|
||||
records = await use_collection('design_progress_record').find_one(
|
||||
{"design_progress_id": _id})
|
||||
start_at = records['send']['date_at']
|
||||
if design_progress.type not in [2,3]:
|
||||
records = await use_collection('design_progress_record').find_one(
|
||||
{"design_progress_id": _id})
|
||||
start_at = records['send']['date_at']
|
||||
else:
|
||||
design_progress_before = await use_collection(COLLECTION).find_one({
|
||||
"type":design_progress.type-1,"project_id":design_progress.project_id
|
||||
})
|
||||
if design_progress_before and "complete_at" in design_progress_before:
|
||||
start_at = design_progress_before["complete_at"]
|
||||
await use_collection(COLLECTION).update_one({"_id": _id}, {"$set": {
|
||||
"start_at": start_at, "complete_at": _inp.complete_at
|
||||
}})
|
||||
@@ -91,20 +99,6 @@ class DesignProgressRepository(BaseRepository[CreateDesignProgress]):
|
||||
|
||||
return result
|
||||
|
||||
async def check_create_complete(self, get_record: GetRecord):
|
||||
result = False
|
||||
if get_record.type and get_record.type > 1:
|
||||
progress = await use_collection(COLLECTION).find(
|
||||
{"project_id": get_record.project_id, "type": int(get_record.type) + 1}).to_list(None)
|
||||
if progress:
|
||||
ids = [i["_id"] for i in progress]
|
||||
records = await use_collection('design_progress_record').find_one(
|
||||
{"design_progress_id": {"$in": ids}})
|
||||
if records:
|
||||
result = True
|
||||
return result
|
||||
|
||||
|
||||
class DesignProgressRecordRepository(BaseRepository[RecordModel]):
|
||||
def __int__(self):
|
||||
super().__init__(collection='design_progress_record', model=RecordModel)
|
||||
|
||||
Reference in New Issue
Block a user