2024-03-16 06:50:18 +03:30
|
|
|
import uuid
|
|
|
|
|
|
|
|
|
|
from app.config import TaskEnv
|
2024-03-15 23:06:46 +03:30
|
|
|
from app.models.register_status import RegisterStatusModel
|
|
|
|
|
from core.repositories.base import BaseRepository
|
2024-03-16 06:50:18 +03:30
|
|
|
from core.service.mongo_db import use_collection
|
2024-03-15 23:06:46 +03:30
|
|
|
|
2024-03-25 20:44:47 +03:30
|
|
|
class RegisterStatusRepository(BaseRepository):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
super().__init__(collection=TaskEnv.CLN_AUDIT_STATUS, model=RegisterStatusModel)
|
2024-03-16 06:50:18 +03:30
|
|
|
|
|
|
|
|
async def get_last(self,project_id:uuid.UUID):
|
2024-03-16 06:55:10 +03:30
|
|
|
last = await use_collection(TaskEnv.CLN_AUDIT_STATUS).find({"project_id":project_id}).sort('$natural', -1).to_list(1)
|
2025-01-20 23:38:02 +03:30
|
|
|
if last and len(last) > 0 and 'number' in last[0]:
|
2024-03-16 06:57:04 +03:30
|
|
|
return last[0]['number']
|
|
|
|
|
else:
|
|
|
|
|
return None
|
2024-06-20 16:22:33 +03:30
|
|
|
|
|
|
|
|
async def get_list(self,project_id:uuid.UUID):
|
|
|
|
|
list_status = await use_collection(TaskEnv.CLN_AUDIT_STATUS).find({"project_id":project_id}).to_list(None)
|
|
|
|
|
return list_status
|