28 lines
1.2 KiB
Python
28 lines
1.2 KiB
Python
import uuid
|
|
|
|
from app.config import TaskEnv
|
|
from app.models.monito_physical_progress import LastRecord
|
|
from app.models.monitor_rial_progress import RialProgressModel
|
|
from app.repositories.monitor_physical_progress import PhysicalProgressRepository
|
|
from app.repositories.project import ProjectRepository
|
|
from core.repositories.base import BaseRepository
|
|
from core.service.mongo_db import use_collection
|
|
from core.utils.crudify import mongo_inserter
|
|
|
|
|
|
class RialProgressRepository(BaseRepository):
|
|
def __init__(self):
|
|
super().__init__(collection=TaskEnv.CLN_MONITOR_RIAL, model=RialProgressModel)
|
|
|
|
async def last_record(self, _inp: LastRecord):
|
|
last = await PhysicalProgressRepository().search_last(TaskEnv.CLN_MONITOR_RIAL, _inp, 35, 25)
|
|
return last
|
|
|
|
async def create(self,_inp:RialProgressModel):
|
|
create = await mongo_inserter(_inp,TaskEnv.CLN_MONITOR_RIAL,getter=self.get)
|
|
await ProjectRepository().set_sts_two_for_monitor(_inp.project_id)
|
|
return create
|
|
|
|
async def list_by_project(self, _id: uuid.UUID):
|
|
_get = await use_collection(TaskEnv.CLN_MONITOR_RIAL).find({"project_id": _id}).to_list(None)
|
|
return _get |