Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/db.py
Show First 20 Lines • Show All 575 Lines • ▼ Show 20 Lines | def origin_visit_get(self, origin_id, visit_id, cur=None): | ||||
""" % (', '.join(self.origin_visit_get_cols[:-1])) | """ % (', '.join(self.origin_visit_get_cols[:-1])) | ||||
cur.execute(query, (origin_id, visit_id)) | cur.execute(query, (origin_id, visit_id)) | ||||
r = cur.fetchall() | r = cur.fetchall() | ||||
if not r: | if not r: | ||||
return None | return None | ||||
return line_to_bytes(r[0]) | return line_to_bytes(r[0]) | ||||
def origin_visit_exists(self, origin_id, visit_id, cur=None): | |||||
anlambert: s/ids/id/ | |||||
Done Inline ActionsNope: origin id + visit id vlorentz: Nope: origin id + visit id | |||||
"""Check whether an origin visit with the given ids exists""" | |||||
cur = self._cursor(cur) | |||||
query = "SELECT 1 FROM origin_visit where origin = %s AND visit = %s" | |||||
cur.execute(query, (origin_id, visit_id)) | |||||
return bool(cur.fetchone()) | |||||
def origin_visit_get_latest_snapshot(self, origin_id, | def origin_visit_get_latest_snapshot(self, origin_id, | ||||
allowed_statuses=None, | allowed_statuses=None, | ||||
cur=None): | cur=None): | ||||
"""Retrieve the most recent origin_visit which references a snapshot | """Retrieve the most recent origin_visit which references a snapshot | ||||
Args: | Args: | ||||
origin_id: the origin concerned | origin_id: the origin concerned | ||||
allowed_statuses: the visit statuses allowed for the returned visit | allowed_statuses: the visit statuses allowed for the returned visit | ||||
▲ Show 20 Lines • Show All 458 Lines • Show Last 20 Lines |
s/ids/id/