Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 531 Lines • ▼ Show 20 Lines | class Storage(): | ||||
def revision_add(self, revisions): | def revision_add(self, revisions): | ||||
"""Add revisions to the storage | """Add revisions to the storage | ||||
Args: | Args: | ||||
revisions (Iterable[dict]): iterable of dictionaries representing | revisions (Iterable[dict]): iterable of dictionaries representing | ||||
the individual revisions to add. Each dict has the following | the individual revisions to add. Each dict has the following | ||||
keys: | keys: | ||||
- id (sha1_git): id of the revision to add | - **id** (:class:`sha1_git`): id of the revision to add | ||||
- date (dict): date the revision was written | - **date** (:class:`dict`): date the revision was written | ||||
- committer_date (dict): date the revision got | - **committer_date** (:class:`dict`): date the revision got | ||||
added to the origin | added to the origin | ||||
- committer_date (datetime.DateTime): date the revision got | - **type** (one of 'git', 'tar'): type of the | ||||
added to the origin | revision added | ||||
- committer_date_offset (int): offset from UTC in minutes the | - **directory** (:class:`sha1_git`): the directory the | ||||
revision was added to the origin | revision points at | ||||
- committer_date_neg_utc_offset (boolean): whether a null | - **message** (:class:`bytes`): the message associated with | ||||
committer_date_offset represents a negative UTC offset | the revision | ||||
- type (one of 'git', 'tar'): type of the revision added | - **author** (:class:`Dict[str, bytes]`): dictionary with | ||||
- directory (sha1_git): the directory the revision points at | keys: name, fullname, email | ||||
- message (bytes): the message associated with the revision | - **committer** (:class:`Dict[str, bytes]`): dictionary with | ||||
- author (Dict[str, bytes]): dictionary with keys: | keys: name, fullname, email | ||||
name, fullname, email | - **metadata** (:class:`jsonb`): extra information as | ||||
- committer (Dict[str, bytes]): dictionary with keys: | dictionary | ||||
name, fullname, email | - **synthetic** (:class:`bool`): revision's nature (tarball, | ||||
- metadata (jsonb): extra information as dictionary | directory creates synthetic revision`) | ||||
- synthetic (bool): revision's nature (tarball, directory | - **parents** (:class:`list[sha1_git]`): the parents of | ||||
creates synthetic revision) | this revision | ||||
- parents (list of sha1_git): the parents of this revision | |||||
date dictionaries have the form defined in :mod:`swh.model`. | date dictionaries have the form defined in :mod:`swh.model`. | ||||
""" | """ | ||||
db = self.get_db() | db = self.get_db() | ||||
revisions_missing = set(self.revision_missing( | revisions_missing = set(self.revision_missing( | ||||
set(revision['id'] for revision in revisions))) | set(revision['id'] for revision in revisions))) | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | class Storage(): | ||||
def release_add(self, releases): | def release_add(self, releases): | ||||
"""Add releases to the storage | """Add releases to the storage | ||||
Args: | Args: | ||||
releases (Iterable[dict]): iterable of dictionaries representing | releases (Iterable[dict]): iterable of dictionaries representing | ||||
the individual releases to add. Each dict has the following | the individual releases to add. Each dict has the following | ||||
keys: | keys: | ||||
- id (sha1_git): id of the release to add | - **id** (:class:`sha1_git`): id of the release to add | ||||
- revision (sha1_git): id of the revision the release points to | - **revision** (:class:`sha1_git`): id of the revision the | ||||
- date (dict): the date the release was made | release points to | ||||
- date_neg_utc_offset (boolean): whether a null date_offset | - **date** (:class:`dict`): the date the release was made | ||||
represents a negative UTC offset | - **name** (:class:`bytes`): the name of the release | ||||
- name (bytes): the name of the release | - **comment** (:class:`bytes`): the comment associated with | ||||
- comment (bytes): the comment associated with the release | the release | ||||
- author (Dict[str, bytes]): dictionary with keys: | - **author** (:class:`Dict[str, bytes]`): dictionary with | ||||
name, fullname, email | keys: name, fullname, email | ||||
the date dictionary has the form defined in :mod:`swh.model`. | the date dictionary has the form defined in :mod:`swh.model`. | ||||
""" | """ | ||||
db = self.get_db() | db = self.get_db() | ||||
release_ids = set(release['id'] for release in releases) | release_ids = set(release['id'] for release in releases) | ||||
releases_missing = set(self.release_missing(release_ids)) | releases_missing = set(self.release_missing(release_ids)) | ||||
▲ Show 20 Lines • Show All 787 Lines • Show Last 20 Lines |