Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cassandra/storage.py
Show First 20 Lines • Show All 577 Lines • ▼ Show 20 Lines | class CassandraStorage: | ||||
def snapshot_get_by_origin_visit(self, origin, visit): | def snapshot_get_by_origin_visit(self, origin, visit): | ||||
try: | try: | ||||
visit = self.origin_visit_get_by(origin, visit) | visit = self.origin_visit_get_by(origin, visit) | ||||
except IndexError: | except IndexError: | ||||
return None | return None | ||||
return self.snapshot_get(visit["snapshot"]) | return self.snapshot_get(visit["snapshot"]) | ||||
def snapshot_get_latest(self, origin, allowed_statuses=None): | |||||
visit = self.origin_visit_get_latest( | |||||
origin, allowed_statuses=allowed_statuses, require_snapshot=True | |||||
) | |||||
if visit: | |||||
assert visit["snapshot"] | |||||
if self._cql_runner.snapshot_missing([visit["snapshot"]]): | |||||
raise StorageArgumentException("Visit references unknown snapshot") | |||||
return self.snapshot_get_branches(visit["snapshot"]) | |||||
def snapshot_count_branches(self, snapshot_id): | def snapshot_count_branches(self, snapshot_id): | ||||
if self._cql_runner.snapshot_missing([snapshot_id]): | if self._cql_runner.snapshot_missing([snapshot_id]): | ||||
# Makes sure we don't fetch branches for a snapshot that is | # Makes sure we don't fetch branches for a snapshot that is | ||||
# being added. | # being added. | ||||
return None | return None | ||||
rows = list(self._cql_runner.snapshot_count_branches(snapshot_id)) | rows = list(self._cql_runner.snapshot_count_branches(snapshot_id)) | ||||
assert len(rows) == 1 | assert len(rows) == 1 | ||||
(nb_none, counts) = rows[0].counts | (nb_none, counts) = rows[0].counts | ||||
▲ Show 20 Lines • Show All 557 Lines • Show Last 20 Lines |