feat: log fetch errors
This commit is contained in:
parent
fc25a8fb8c
commit
39256e03ad
1 changed files with 11 additions and 4 deletions
15
threads.py
15
threads.py
|
|
@ -48,6 +48,7 @@ def get_account_tagged_statuses(tag_name):
|
||||||
statuses = [utils.clean_status(s) for s in statuses]
|
statuses = [utils.clean_status(s) for s in statuses]
|
||||||
return statuses
|
return statuses
|
||||||
else:
|
else:
|
||||||
|
current_app.logger.error(f"get_account_tagged_statuses returned: {response.status_code}", url)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def get_featured_tags():
|
def get_featured_tags():
|
||||||
|
|
@ -59,6 +60,7 @@ def get_featured_tags():
|
||||||
tags = response.json()
|
tags = response.json()
|
||||||
return tags
|
return tags
|
||||||
else:
|
else:
|
||||||
|
current_app.logger.error(f"get_featured_tags returned: {response.status_code}", url)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
### middleware
|
### middleware
|
||||||
|
|
@ -78,7 +80,8 @@ def get_status_url(ser, id):
|
||||||
|
|
||||||
def fetch_statuses(ids):
|
def fetch_statuses(ids):
|
||||||
query_params = "&id[]=".join(ids)
|
query_params = "&id[]=".join(ids)
|
||||||
response = requests.get(server() + '/api/v1/statuses?id[]=' + query_params )
|
url = server() + '/api/v1/statuses?id[]=' + query_params
|
||||||
|
response = requests.get(url)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
statuses = response.json()
|
statuses = response.json()
|
||||||
|
|
||||||
|
|
@ -88,22 +91,25 @@ def fetch_statuses(ids):
|
||||||
|
|
||||||
return statuses
|
return statuses
|
||||||
else:
|
else:
|
||||||
print(f"response status code: {response.status_code}")
|
current_app.logger.error(f"fetch_statuses returned: {response.status_code}", url)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def fetch_thread(id):
|
def fetch_thread(id):
|
||||||
response = requests.get(server() + '/api/v1/statuses/' + id )
|
url = server() + '/api/v1/statuses/' + id
|
||||||
|
response = requests.get(url)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
status = response.json()
|
status = response.json()
|
||||||
status = utils.clean_status(status)
|
status = utils.clean_status(status)
|
||||||
status['descendants'] = get_descendants(server(), status)
|
status['descendants'] = get_descendants(server(), status)
|
||||||
return status
|
return status
|
||||||
else:
|
else:
|
||||||
|
current_app.logger.error(f"fetch_thread returned: {response.status_code}", url)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_descendants(server, status):
|
def get_descendants(server, status):
|
||||||
author_id = status['account']['id']
|
author_id = status['account']['id']
|
||||||
response = requests.get(server + '/api/v1/statuses/' + status['id'] + '/context')
|
url = server + '/api/v1/statuses/' + status['id'] + '/context'
|
||||||
|
response = requests.get(url)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
context = response.json()
|
context = response.json()
|
||||||
descendants = []
|
descendants = []
|
||||||
|
|
@ -114,6 +120,7 @@ def get_descendants(server, status):
|
||||||
descendants.append(utils.clean_status(reply))
|
descendants.append(utils.clean_status(reply))
|
||||||
return descendants
|
return descendants
|
||||||
else:
|
else:
|
||||||
|
current_app.logger.error(f"get_descendants returned: {response.status_code}", url)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
### routes
|
### routes
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue