Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/db.py
Show First 20 Lines • Show All 256 Lines • ▼ Show 20 Lines | ): | ||||
""" % ", ".join( | """ % ", ".join( | ||||
self.snapshot_get_cols | self.snapshot_get_cols | ||||
) | ) | ||||
cur.execute(query, (snapshot_id, branches_from, branches_count, target_types)) | cur.execute(query, (snapshot_id, branches_from, branches_count, target_types)) | ||||
yield from cur | yield from cur | ||||
def snapshot_get_by_origin_visit(self, origin_url, visit_id, cur=None): | |||||
cur = self._cursor(cur) | |||||
query = """\ | |||||
SELECT ovs.snapshot | |||||
FROM origin_visit ov | |||||
INNER JOIN origin o ON o.id = ov.origin | |||||
INNER JOIN origin_visit_status ovs | |||||
ON ov.origin = ovs.origin AND ov.visit = ovs.visit | |||||
WHERE o.url=%s AND ov.visit=%s | |||||
ORDER BY ovs.date DESC LIMIT 1 | |||||
""" | |||||
cur.execute(query, (origin_url, visit_id)) | |||||
ret = cur.fetchone() | |||||
if ret: | |||||
return ret[0] | |||||
def snapshot_get_random(self, cur=None): | def snapshot_get_random(self, cur=None): | ||||
return self._get_random_row_from_table("snapshot", ["id"], "id", cur) | return self._get_random_row_from_table("snapshot", ["id"], "id", cur) | ||||
content_find_cols = [ | content_find_cols = [ | ||||
"sha1", | "sha1", | ||||
"sha1_git", | "sha1_git", | ||||
"sha256", | "sha256", | ||||
"blake2s256", | "blake2s256", | ||||
▲ Show 20 Lines • Show All 1,058 Lines • Show Last 20 Lines |