refactor: pass ids to fetch_statuses
This commit is contained in:
parent
ce9191ec97
commit
3c1bcfc32b
1 changed files with 4 additions and 5 deletions
|
|
@ -68,7 +68,6 @@ def get_featured_tags():
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
### middleware
|
### middleware
|
||||||
@threads.before_request
|
@threads.before_request
|
||||||
def middleware():
|
def middleware():
|
||||||
|
|
@ -84,8 +83,8 @@ def middleware():
|
||||||
def get_status_url(ser, id):
|
def get_status_url(ser, id):
|
||||||
return f'{ser}/api/v1/statuses/{id}'
|
return f'{ser}/api/v1/statuses/{id}'
|
||||||
|
|
||||||
def fetch_statuses():
|
def fetch_statuses(ids):
|
||||||
query_params = "&id[]=".join(thread_ids)
|
query_params = "&id[]=".join(ids)
|
||||||
response = requests.get(server() + '/api/v1/statuses?id[]=' + query_params )
|
response = requests.get(server() + '/api/v1/statuses?id[]=' + query_params )
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
statuses = response.json()
|
statuses = response.json()
|
||||||
|
|
@ -122,7 +121,7 @@ def get_descendants(server, status):
|
||||||
@threads.route('/')
|
@threads.route('/')
|
||||||
@cache.cached(timeout=300)
|
@cache.cached(timeout=300)
|
||||||
def home():
|
def home():
|
||||||
statuses = fetch_statuses()
|
statuses = fetch_statuses(thread_ids)
|
||||||
attribution = get_attribution()
|
attribution = get_attribution()
|
||||||
app = get_app_config()
|
app = get_app_config()
|
||||||
tags = []
|
tags = []
|
||||||
|
|
@ -165,7 +164,7 @@ def thread(id):
|
||||||
@threads.route('/api')
|
@threads.route('/api')
|
||||||
@cache.cached(timeout=300)
|
@cache.cached(timeout=300)
|
||||||
def api():
|
def api():
|
||||||
return fetch_statuses();
|
return fetch_statuses(thread_ids);
|
||||||
|
|
||||||
@threads.route('/api/<path:id>')
|
@threads.route('/api/<path:id>')
|
||||||
@cache.cached(timeout=300)
|
@cache.cached(timeout=300)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue