定时任务优化
This commit is contained in:
@@ -58,6 +58,13 @@ class AccountService:
|
||||
return AccountResponse.from_orm_account(account)
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def get_accounts_batch(db: Session, account_ids: List[int]) -> List[Account]:
|
||||
"""批量根据ID列表获取账号数据(返回模型对象,用于批量关联)"""
|
||||
if not account_ids:
|
||||
return []
|
||||
return db.query(Account).filter(Account.id.in_(account_ids)).all()
|
||||
|
||||
@staticmethod
|
||||
def get_account_by_username(db: Session, username: str) -> Optional[Account]:
|
||||
"""根据用户名获取账号"""
|
||||
|
||||
@@ -15,6 +15,12 @@ class CheckpointService(BaseService[Checkpoint]):
|
||||
checkpoints = self.get_by_field(db, "point_id", point_id)
|
||||
return checkpoints[0] if checkpoints else None
|
||||
|
||||
def get_by_point_ids_batch(self, db: Session, point_ids: List[str]) -> List[Checkpoint]:
|
||||
"""批量根据观测点ID列表获取观测点数据(使用IN查询优化性能)"""
|
||||
if not point_ids:
|
||||
return []
|
||||
return db.query(Checkpoint).filter(Checkpoint.point_id.in_(point_ids)).all()
|
||||
|
||||
def search_checkpoints(self, db: Session,
|
||||
aname: Optional[str] = None,
|
||||
section_id: Optional[str] = None,
|
||||
|
||||
@@ -30,6 +30,13 @@ class SectionDataService(BaseService[SectionData]):
|
||||
if not account_ids:
|
||||
return []
|
||||
return db.query(SectionData).filter(SectionData.account_id.in_(account_ids)).all()
|
||||
|
||||
def get_by_section_ids_batch(self, db: Session, section_ids: List[str]) -> List[SectionData]:
|
||||
"""批量根据断面ID列表获取断面数据(使用IN查询优化性能)"""
|
||||
if not section_ids:
|
||||
return []
|
||||
return db.query(SectionData).filter(SectionData.section_id.in_(section_ids)).all()
|
||||
|
||||
def get_by_number(self, db: Session, number: str) -> List[SectionData]:
|
||||
"""根据桥梁墩(台)编号获取断面数据"""
|
||||
return self.get_by_field(db, "number", number)
|
||||
|
||||
Reference in New Issue
Block a user