Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 1,167 Lines • ▼ Show 20 Lines | def origin_search(self, url_pattern, offset=0, limit=50, | ||||
Yields: | Yields: | ||||
dicts containing origin information as returned | dicts containing origin information as returned | ||||
by :meth:`swh.storage.storage.Storage.origin_get`. | by :meth:`swh.storage.storage.Storage.origin_get`. | ||||
""" | """ | ||||
for origin in db.origin_search(url_pattern, offset, limit, | for origin in db.origin_search(url_pattern, offset, limit, | ||||
regexp, with_visit, cur): | regexp, with_visit, cur): | ||||
yield dict(zip(self.origin_keys, origin)) | yield dict(zip(self.origin_keys, origin)) | ||||
@db_transaction() | |||||
def origin_count(self, url_pattern, regexp=False, | |||||
with_visit=False, db=None, cur=None): | |||||
"""Count origins whose urls contain a provided string pattern | |||||
or match a provided regular expression. | |||||
The pattern search in origin urls is performed in a case insensitive | |||||
way. | |||||
Args: | |||||
url_pattern (str): the string pattern to search for in origin urls | |||||
regexp (bool): if True, consider the provided pattern as a regular | |||||
expression and return origins whose urls match it | |||||
with_visit (bool): if True, filter out origins with no visit | |||||
Returns: | |||||
int: The number of origins matching the search criterion. | |||||
""" | |||||
return db.origin_count(url_pattern, regexp, with_visit, cur) | |||||
@db_transaction_generator() | @db_transaction_generator() | ||||
def origin_get_range(self, origin_from=1, origin_count=100, | def origin_get_range(self, origin_from=1, origin_count=100, | ||||
db=None, cur=None): | db=None, cur=None): | ||||
"""Retrieve ``origin_count`` origins whose ids are greater | """Retrieve ``origin_count`` origins whose ids are greater | ||||
or equal than ``origin_from``. | or equal than ``origin_from``. | ||||
Origins are sorted by id before retrieving them. | Origins are sorted by id before retrieving them. | ||||
▲ Show 20 Lines • Show All 333 Lines • Show Last 20 Lines |