swh.web.utils.origin_visits module#

swh.web.utils.origin_visits.get_origin_visits(origin_url: str, lookup_similar_urls: bool = True, visit_type: str | None = None) List[OriginVisitInfo][source]#

Function that returns the list of visits for a swh origin. That list is put in cache in order to speedup the navigation in the swh web browse ui.

The returned visits are sorted according to their date in ascending order.

Parameters:
  • origin_url – URL of origin

  • lookup_similar_urls – if True, lookup origin with and without trailing slash in its URL

Returns:

A list of dict describing the origin visits

Raises:

swh.web.utils.exc.NotFoundExc – if the origin is not found

swh.web.utils.origin_visits.get_origin_visit(origin_url: str, visit_ts: str | None = None, visit_id: int | None = None, snapshot_id: str | None = None, visit_type: str | None = None) OriginVisitInfo[source]#

Function that returns information about a visit for a given origin.

If a timestamp is provided, the closest visit from that timestamp is returned.

If a snapshot identifier is provided, the first visit with that snapshot is returned.

If no search hints are provided, return the most recent full visit with a valid snapshot or the most recent partial visit with a valid snapshot otherwise.

Parameters:
  • origin_url – URL of origin

  • visit_ts – an ISO 8601 datetime string to parse

  • snapshot_id – a snapshot identifier

Returns:

A dict containing the visit info.

Raises:

swh.web.utils.exc.NotFoundExc – if no visit can be found