Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/in_memory.py
Show First 20 Lines • Show All 749 Lines • ▼ Show 20 Lines | ) -> PagedResult[Origin]: | ||||
# next offset | # next offset | ||||
next_page_token = str(offset + limit) | next_page_token = str(offset + limit) | ||||
# excluding that origin from the result to respect the limit size | # excluding that origin from the result to respect the limit size | ||||
origins = origins[:limit] | origins = origins[:limit] | ||||
assert len(origins) <= limit | assert len(origins) <= limit | ||||
return PagedResult(results=origins, next_page_token=next_page_token) | return PagedResult(results=origins, next_page_token=next_page_token) | ||||
def origin_count(self, url_pattern, regexp=False, with_visit=False): | def origin_count( | ||||
self, url_pattern: str, regexp: bool = False, with_visit: bool = False | |||||
) -> int: | |||||
actual_page = self.origin_search( | actual_page = self.origin_search( | ||||
url_pattern, regexp=regexp, with_visit=with_visit, limit=len(self._origins), | url_pattern, regexp=regexp, with_visit=with_visit, limit=len(self._origins), | ||||
) | ) | ||||
assert actual_page.next_page_token is None | assert actual_page.next_page_token is None | ||||
return len(actual_page.results) | return len(actual_page.results) | ||||
def origin_add(self, origins: List[Origin]) -> Dict[str, int]: | def origin_add(self, origins: List[Origin]) -> Dict[str, int]: | ||||
added = 0 | added = 0 | ||||
▲ Show 20 Lines • Show All 505 Lines • Show Last 20 Lines |