Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/service.py
Show First 20 Lines • Show All 892 Lines • ▼ Show 20 Lines | Returns: | ||||
values their corresponding amount | values their corresponding amount | ||||
""" | """ | ||||
snapshot_id_bin = _to_sha1_bin(snapshot_id) | snapshot_id_bin = _to_sha1_bin(snapshot_id) | ||||
snapshot_size = storage.snapshot_count_branches(snapshot_id_bin) | snapshot_size = storage.snapshot_count_branches(snapshot_id_bin) | ||||
if 'revision' not in snapshot_size: | if 'revision' not in snapshot_size: | ||||
snapshot_size['revision'] = 0 | snapshot_size['revision'] = 0 | ||||
if 'release' not in snapshot_size: | if 'release' not in snapshot_size: | ||||
snapshot_size['release'] = 0 | snapshot_size['release'] = 0 | ||||
# adjust revision / release count for display if aliases are defined | |||||
if 'alias' in snapshot_size: | |||||
aliases = lookup_snapshot(snapshot_id, | |||||
branches_count=snapshot_size['alias'], | |||||
target_types=['alias']) | |||||
for alias in aliases['branches'].values(): | |||||
if lookup_snapshot(snapshot_id, | |||||
branches_from=alias['target'], | |||||
branches_count=1, | |||||
target_types=['revision']): | |||||
snapshot_size['revision'] += 1 | |||||
else: | |||||
snapshot_size['release'] += 1 | |||||
del snapshot_size['alias'] | |||||
return snapshot_size | return snapshot_size | ||||
def lookup_snapshot(snapshot_id, branches_from='', branches_count=1000, | def lookup_snapshot(snapshot_id, branches_from='', branches_count=1000, | ||||
target_types=None): | target_types=None): | ||||
"""Return information about a snapshot, aka the list of named | """Return information about a snapshot, aka the list of named | ||||
branches found during a specific visit of an origin. | branches found during a specific visit of an origin. | ||||
▲ Show 20 Lines • Show All 193 Lines • Show Last 20 Lines |