fix:last record
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
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
|
||||
@@ -12,12 +14,9 @@ class RialProgressRepository(BaseRepository):
|
||||
def __init__(self):
|
||||
super().__init__(collection=TaskEnv.CLN_MONITOR_RIAL, model=RialProgressModel)
|
||||
|
||||
async def last_record(self, project_id:uuid.UUID):
|
||||
last = await use_collection(TaskEnv.CLN_MONITOR_RIAL).find({'project_id':project_id}).sort("$natural", -1).to_list(None)
|
||||
if last:
|
||||
return last[0]
|
||||
else:
|
||||
return {}
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user