fix:design progress
This commit is contained in:
@@ -12,11 +12,12 @@ from core.service.mongo_db import use_collection
|
||||
from core.utils.crudify import mongo_soft_deleter
|
||||
|
||||
COLLECTION = "design_progress"
|
||||
|
||||
|
||||
class DesignProgressRepository(BaseRepository[CreateDesignProgress]):
|
||||
def __int__(self):
|
||||
super().__init__(collection=COLLECTION, model=CreateDesignProgress)
|
||||
|
||||
|
||||
async def create(self, _inp: CreateDesignProgress):
|
||||
exist = await use_collection(COLLECTION).find_one({
|
||||
"project_id": _inp.project_id,
|
||||
@@ -40,9 +41,11 @@ class DesignProgressRepository(BaseRepository[CreateDesignProgress]):
|
||||
return await self.get(get_record)
|
||||
|
||||
async def get(self, get_record: GetRecord):
|
||||
progress = await use_collection(COLLECTION).find_one({"project_id":get_record.project_id,"type":get_record.type,"sub_type":get_record.sub_type})
|
||||
progress = await use_collection(COLLECTION).find_one(
|
||||
{"project_id": get_record.project_id, "type": get_record.type, "sub_type": get_record.sub_type})
|
||||
if progress:
|
||||
progress['records'] = await use_collection('design_progress_record').find({"design_progress_id":progress["_id"]}).to_list(None)
|
||||
progress['records'] = await use_collection('design_progress_record').find(
|
||||
{"design_progress_id": progress["_id"]}).to_list(None)
|
||||
return progress
|
||||
|
||||
async def update(self, _id: UUID, _inp: UpdateDesignProgress):
|
||||
@@ -64,6 +67,7 @@ class DesignProgressRepository(BaseRepository[CreateDesignProgress]):
|
||||
sub_type=design_progress.sub_type
|
||||
)
|
||||
return await self.get(get_record)
|
||||
|
||||
async def check_complete(self, get_record: GetRecord):
|
||||
result = {
|
||||
"exist": False
|
||||
@@ -72,7 +76,7 @@ class DesignProgressRepository(BaseRepository[CreateDesignProgress]):
|
||||
if get_record.type > 1:
|
||||
progress = await use_collection(COLLECTION).find_one(
|
||||
{"project_id": get_record.project_id, "type": int(get_record.type) - 1,
|
||||
"completed_at": {"$exists": 1}})
|
||||
"completed_at": {"$exists": 1},"sub_type":{"$exists":0}})
|
||||
if not progress:
|
||||
return {"exist": True, "detail": 'before type not complete'}
|
||||
if get_record.type < 7:
|
||||
@@ -104,5 +108,3 @@ class DesignProgressRepository(BaseRepository[CreateDesignProgress]):
|
||||
class DesignProgressRecordRepository(BaseRepository[RecordModel]):
|
||||
def __int__(self):
|
||||
super().__init__(collection='design_progress_record', model=RecordModel)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user