Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/postgresql/storage.py
Show First 20 Lines • Show All 637 Lines • ▼ Show 20 Lines | class Storage: | ||||
@db_transaction() | @db_transaction() | ||||
def revision_get_random(self, db=None, cur=None) -> Sha1Git: | def revision_get_random(self, db=None, cur=None) -> Sha1Git: | ||||
return db.revision_get_random(cur) | return db.revision_get_random(cur) | ||||
@timed | @timed | ||||
@db_transaction() | @db_transaction() | ||||
def extid_get_from_extid( | def extid_get_from_extid( | ||||
self, id_type: str, ids: List[bytes], db=None, cur=None | self, id_type: str, ids: List[bytes], db=None, cur=None | ||||
) -> List[Optional[ExtID]]: | ) -> List[ExtID]: | ||||
extids = [] | extids = [] | ||||
for row in db.extid_get_from_extid_list(id_type, ids, cur): | for row in db.extid_get_from_extid_list(id_type, ids, cur): | ||||
extids.append( | if row[0] is not None: | ||||
converters.db_to_extid(dict(zip(db.extid_cols, row))) | extids.append(converters.db_to_extid(dict(zip(db.extid_cols, row)))) | ||||
if row[0] is not None | |||||
else None | |||||
) | |||||
return extids | return extids | ||||
@timed | @timed | ||||
@db_transaction() | @db_transaction() | ||||
def extid_get_from_target( | def extid_get_from_target( | ||||
self, target_type: ObjectType, ids: List[Sha1Git], db=None, cur=None | self, target_type: ObjectType, ids: List[Sha1Git], db=None, cur=None | ||||
) -> List[Optional[ExtID]]: | ) -> List[ExtID]: | ||||
extids = [] | extids = [] | ||||
for row in db.extid_get_from_swhid_list(target_type.value, ids, cur): | for row in db.extid_get_from_swhid_list(target_type.value, ids, cur): | ||||
extids.append( | if row[0] is not None: | ||||
converters.db_to_extid(dict(zip(db.extid_cols, row))) | extids.append(converters.db_to_extid(dict(zip(db.extid_cols, row)))) | ||||
if row[0] is not None | |||||
else None | |||||
) | |||||
return extids | return extids | ||||
@timed | @timed | ||||
@db_transaction() | @db_transaction() | ||||
def extid_add(self, ids: List[ExtID], db=None, cur=None) -> Dict[str, int]: | def extid_add(self, ids: List[ExtID], db=None, cur=None) -> Dict[str, int]: | ||||
extid = [ | extid = [ | ||||
{ | { | ||||
"extid": extid.extid, | "extid": extid.extid, | ||||
▲ Show 20 Lines • Show All 803 Lines • Show Last 20 Lines |