Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/service.py
Show First 20 Lines • Show All 895 Lines • ▼ Show 20 Lines | for visit in visits: | ||||
visit_status = storage.origin_visit_status_get_latest(origin, visit["visit"]) | visit_status = storage.origin_visit_status_get_latest(origin, visit["visit"]) | ||||
yield converters.from_origin_visit({**visit, **visit_status.to_dict()}) | yield converters.from_origin_visit({**visit, **visit_status.to_dict()}) | ||||
def lookup_origin_visit_latest( | def lookup_origin_visit_latest( | ||||
origin_url: str, | origin_url: str, | ||||
require_snapshot: bool = False, | require_snapshot: bool = False, | ||||
type: Optional[str] = None, | type: Optional[str] = None, | ||||
allowed_statuses: Optional[Iterable[str]] = None, | allowed_statuses: Optional[List[str]] = None, | ||||
) -> Optional[OriginVisitInfo]: | ) -> Optional[OriginVisitInfo]: | ||||
"""Return the origin's latest visit | """Return the origin's latest visit | ||||
Args: | Args: | ||||
origin_url: origin to list visits for | origin_url: origin to list visits for | ||||
type: Optional visit type to filter on (e.g git, tar, dsc, svn, | type: Optional visit type to filter on (e.g git, tar, dsc, svn, | ||||
hg, npm, pypi, ...) | hg, npm, pypi, ...) | ||||
allowed_statuses: list of visit statuses considered | allowed_statuses: list of visit statuses considered | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | snapshot = storage.snapshot_get_branches( | ||||
snapshot_id_bin, branches_from.encode(), branches_count, target_types | snapshot_id_bin, branches_from.encode(), branches_count, target_types | ||||
) | ) | ||||
if not snapshot: | if not snapshot: | ||||
raise NotFoundExc("Snapshot with id %s not found!" % snapshot_id) | raise NotFoundExc("Snapshot with id %s not found!" % snapshot_id) | ||||
return converters.from_snapshot(snapshot) | return converters.from_snapshot(snapshot) | ||||
def lookup_latest_origin_snapshot( | def lookup_latest_origin_snapshot( | ||||
origin: str, allowed_statuses: Iterable[str] = None | origin: str, allowed_statuses: List[str] = None | ||||
) -> Optional[Dict[str, Any]]: | ) -> Optional[Dict[str, Any]]: | ||||
"""Return information about the latest snapshot of an origin. | """Return information about the latest snapshot of an origin. | ||||
.. warning:: At most 1000 branches contained in the snapshot | .. warning:: At most 1000 branches contained in the snapshot | ||||
will be returned for performance reasons. | will be returned for performance reasons. | ||||
Args: | Args: | ||||
origin: URL or integer identifier of the origin | origin: URL or integer identifier of the origin | ||||
▲ Show 20 Lines • Show All 272 Lines • Show Last 20 Lines |