Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/phabricator/lister.py
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | def get_model_from_repo(self, repo): | ||||
'html_url': url, | 'html_url': url, | ||||
'origin_url': url, | 'origin_url': url, | ||||
'origin_type': repo['fields']['vcs'], | 'origin_type': repo['fields']['vcs'], | ||||
'instance': self.instance, | 'instance': self.instance, | ||||
} | } | ||||
def get_next_target_from_response(self, response): | def get_next_target_from_response(self, response): | ||||
body = response.json()['result']['cursor'] | body = response.json()['result']['cursor'] | ||||
if body['after'] != 'null': | if body['after'] and body['after'] != 'null': | ||||
return body['after'] | return int(body['after']) | ||||
return None | |||||
def transport_response_simplified(self, response): | def transport_response_simplified(self, response): | ||||
repos = response.json() | repos = response.json() | ||||
if repos['result'] is None: | if repos['result'] is None: | ||||
raise ValueError( | raise ValueError( | ||||
'Problem during information fetch: %s' % repos['error_code']) | 'Problem during information fetch: %s' % repos['error_code']) | ||||
repos = repos['result']['data'] | repos = repos['result']['data'] | ||||
return [self.get_model_from_repo(repo) for repo in repos] | return [self.get_model_from_repo(repo) for repo in repos] | ||||
Show All 20 Lines | def _bootstrap_repositories_listing(self): | ||||
after that value | after that value | ||||
Returns: | Returns: | ||||
int: The first repository index | int: The first repository index | ||||
""" | """ | ||||
params = '&order=oldest&limit=1' | params = '&order=oldest&limit=1' | ||||
response = self.safely_issue_request(params) | response = self.safely_issue_request(params) | ||||
models_list = self.transport_response_simplified(response) | models_list = self.transport_response_simplified(response) | ||||
self.max_index = models_list[0]['indexable'] | |||||
models_list = self.filter_before_inject(models_list) | models_list = self.filter_before_inject(models_list) | ||||
injected = self.inject_repo_data_into_db(models_list) | injected = self.inject_repo_data_into_db(models_list) | ||||
self.schedule_missing_tasks(models_list, injected) | self.schedule_missing_tasks(models_list, injected) | ||||
return self.max_index | return models_list[0]['indexable'] | ||||
def get_repo_url(attachments): | def get_repo_url(attachments): | ||||
""" | """ | ||||
Return url for a hosted repository from its uris attachments according | Return url for a hosted repository from its uris attachments according | ||||
to the following priority lists: | to the following priority lists: | ||||
* protocol: https > http | * protocol: https > http | ||||
* identifier: shortname > callsign > id | * identifier: shortname > callsign > id | ||||
Show All 19 Lines |