Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/backend.py
Show First 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | def get_listers(self, db=None, cur=None) -> List[Lister]: | ||||
select {select_cols} from listers | select {select_cols} from listers | ||||
""" | """ | ||||
cur.execute(query) | cur.execute(query) | ||||
return [Lister(**ret) for ret in cur.fetchall()] | return [Lister(**ret) for ret in cur.fetchall()] | ||||
@db_transaction() | @db_transaction() | ||||
def get_listers_by_id( | |||||
self, lister_ids: List[str], db=None, cur=None | |||||
) -> List[Lister]: | |||||
"""Retrieve listers in batch, using their UUID""" | |||||
select_cols = ", ".join(Lister.select_columns()) | |||||
query = f""" | |||||
select {select_cols} from listers | |||||
where id in %s | |||||
""" | |||||
cur.execute(query, (tuple(lister_ids),)) | |||||
return [Lister(**row) for row in cur] | |||||
@db_transaction() | |||||
def get_lister( | def get_lister( | ||||
self, name: str, instance_name: Optional[str] = None, db=None, cur=None | self, name: str, instance_name: Optional[str] = None, db=None, cur=None | ||||
) -> Optional[Lister]: | ) -> Optional[Lister]: | ||||
"""Retrieve information about the given instance of the lister from the | """Retrieve information about the given instance of the lister from the | ||||
database. | database. | ||||
""" | """ | ||||
if instance_name is None: | if instance_name is None: | ||||
instance_name = "" | instance_name = "" | ||||
▲ Show 20 Lines • Show All 950 Lines • Show Last 20 Lines |