Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cassandra/storage.py
Show First 20 Lines • Show All 942 Lines • ▼ Show 20 Lines | ) -> Optional[Dict[str, Any]]: | ||||
continue | continue | ||||
if updated_visit["visit"] < latest_visit["visit"]: | if updated_visit["visit"] < latest_visit["visit"]: | ||||
continue | continue | ||||
latest_visit = updated_visit | latest_visit = updated_visit | ||||
return latest_visit | return latest_visit | ||||
def origin_visit_status_get_latest( | |||||
self, | |||||
origin_url: str, | |||||
visit: int, | |||||
allowed_statuses: Optional[List[str]] = None, | |||||
require_snapshot: bool = False, | |||||
) -> Optional[OriginVisitStatus]: | |||||
visit_status = self._cql_runner.origin_visit_status_get_latest( | |||||
origin_url, visit, allowed_statuses, require_snapshot | |||||
) | |||||
if not visit_status: | |||||
return None | |||||
return OriginVisitStatus.from_dict(visit_status) | |||||
def origin_visit_get_random(self, type: str) -> Optional[Dict[str, Any]]: | def origin_visit_get_random(self, type: str) -> Optional[Dict[str, Any]]: | ||||
back_in_the_day = now() - datetime.timedelta(weeks=12) # 3 months back | back_in_the_day = now() - datetime.timedelta(weeks=12) # 3 months back | ||||
# Random position to start iteration at | # Random position to start iteration at | ||||
start_token = random.randint(TOKEN_BEGIN, TOKEN_END) | start_token = random.randint(TOKEN_BEGIN, TOKEN_END) | ||||
# Iterator over all visits, ordered by token(origins) then visit_id | # Iterator over all visits, ordered by token(origins) then visit_id | ||||
rows = self._cql_runner.origin_visit_iter(start_token) | rows = self._cql_runner.origin_visit_iter(start_token) | ||||
▲ Show 20 Lines • Show All 180 Lines • Show Last 20 Lines |