Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 908 Lines • ▼ Show 20 Lines | def snapshot_get_branches(self, snapshot_id, branches_from=b'', | ||||
return {'id': snapshot_id, 'branches': branches} | return {'id': snapshot_id, 'branches': branches} | ||||
if db.snapshot_exists(snapshot_id, cur): | if db.snapshot_exists(snapshot_id, cur): | ||||
return {'id': snapshot_id, 'branches': {}} | return {'id': snapshot_id, 'branches': {}} | ||||
return None | return None | ||||
@db_transaction() | @db_transaction() | ||||
def occurrence_add(self, occurrences, db=None, cur=None): | |||||
"""Add occurrences to the storage | |||||
Args: | |||||
occurrences: iterable of dictionaries representing the individual | |||||
occurrences to add. Each dict has the following keys: | |||||
- origin (int): id of the origin corresponding to the | |||||
occurrence | |||||
- visit (int): id of the visit corresponding to the | |||||
occurrence | |||||
- branch (str): the reference name of the occurrence | |||||
- target (sha1_git): the id of the object pointed to by | |||||
the occurrence | |||||
- target_type (str): the type of object pointed to by the | |||||
occurrence | |||||
""" | |||||
db.mktemp_occurrence_history(cur) | |||||
db.copy_to(occurrences, 'tmp_occurrence_history', | |||||
['origin', 'branch', 'target', 'target_type', 'visit'], cur) | |||||
db.occurrence_history_add_from_temp(cur) | |||||
@db_transaction() | |||||
def origin_visit_add(self, origin, ts, db=None, cur=None): | def origin_visit_add(self, origin, ts, db=None, cur=None): | ||||
"""Add an origin_visit for the origin at ts with status 'ongoing'. | """Add an origin_visit for the origin at ts with status 'ongoing'. | ||||
Args: | Args: | ||||
origin: Visited Origin id | origin: Visited Origin id | ||||
ts: timestamp of such visit | ts: timestamp of such visit | ||||
Returns: | Returns: | ||||
▲ Show 20 Lines • Show All 449 Lines • Show Last 20 Lines |