Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 1,310 Lines • ▼ Show 20 Lines | def origin_visit_get(self, origin, last_visit=None, limit=None, db=None, | ||||
Default to None | Default to None | ||||
limit (int): Number of results to return from the last visit. | limit (int): Number of results to return from the last visit. | ||||
Default to None | Default to None | ||||
Yields: | Yields: | ||||
List of visits. | List of visits. | ||||
""" | """ | ||||
if isinstance(origin, str): | |||||
origin = self.origin_get([{'url': origin}], db=db, cur=cur)[0] | |||||
if not origin: | |||||
return | |||||
origin = origin['id'] | |||||
for line in db.origin_visit_get_all( | for line in db.origin_visit_get_all( | ||||
origin, last_visit=last_visit, limit=limit, cur=cur): | origin, last_visit=last_visit, limit=limit, cur=cur): | ||||
data = dict(zip(db.origin_visit_get_cols, line)) | data = dict(zip(db.origin_visit_get_cols, line)) | ||||
yield data | yield data | ||||
@db_transaction(statement_timeout=500) | @db_transaction(statement_timeout=500) | ||||
def origin_visit_find_by_date(self, origin, visit_date, db=None, cur=None): | def origin_visit_find_by_date(self, origin, visit_date, db=None, cur=None): | ||||
"""Retrieves the origin visit whose date is closest to the provided | """Retrieves the origin visit whose date is closest to the provided | ||||
▲ Show 20 Lines • Show All 563 Lines • Show Last 20 Lines |