Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/db.py
Show First 20 Lines • Show All 338 Lines • ▼ Show 20 Lines | class Db(BaseDb): | ||||
def skipped_content_missing_from_temp(self, cur=None): | def skipped_content_missing_from_temp(self, cur=None): | ||||
cur = self._cursor(cur) | cur = self._cursor(cur) | ||||
cur.execute("""SELECT sha1, sha1_git, sha256, blake2s256 | cur.execute("""SELECT sha1, sha1_git, sha256, blake2s256 | ||||
FROM swh_skipped_content_missing()""") | FROM swh_skipped_content_missing()""") | ||||
yield from cursor_to_bytes(cur) | yield from cursor_to_bytes(cur) | ||||
def occurrence_get(self, origin_id, cur=None): | |||||
"""Retrieve latest occurrence's information by origin_id. | |||||
""" | |||||
cur = self._cursor(cur) | |||||
cur.execute("""SELECT origin, branch, target, target_type, | |||||
(select max(date) from origin_visit | |||||
where origin=%s) as date | |||||
FROM occurrence | |||||
WHERE origin=%s | |||||
""", | |||||
(origin_id, origin_id)) | |||||
yield from cursor_to_bytes(cur) | |||||
def snapshot_exists(self, snapshot_id, cur=None): | def snapshot_exists(self, snapshot_id, cur=None): | ||||
"""Check whether a snapshot with the given id exists""" | """Check whether a snapshot with the given id exists""" | ||||
cur = self._cursor(cur) | cur = self._cursor(cur) | ||||
cur.execute("""SELECT 1 FROM snapshot where id=%s""", (snapshot_id,)) | cur.execute("""SELECT 1 FROM snapshot where id=%s""", (snapshot_id,)) | ||||
return bool(cur.fetchone()) | return bool(cur.fetchone()) | ||||
▲ Show 20 Lines • Show All 746 Lines • Show Last 20 Lines |