Skip to content

Commit

Permalink
Use newer version of place stat vars api in website (#1425)
Browse files Browse the repository at this point in the history
* Use newer version of place stat vars api in website

* nit

* update
  • Loading branch information
shifucun authored Jan 28, 2022
1 parent 9fc4277 commit 653be6e
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions server/routes/api/browser.py
Original file line number Diff line number Diff line change
@@ -123,9 +123,9 @@ def get_observation_id():

@cache.memoize(timeout=3600 * 24) # Cache for one day.
@bp.route('/num_stat_vars/<path:dcid>')
def get_num_statvars(dcid):
def get_num_stat_vars(dcid):
"""Returns number of stat vars for a dcid
"""
statsvars = place_api.statsvars(dcid)
num_statvars = len(statsvars)
return Response(json.dumps(num_statvars), 200, mimetype='application/json')
stat_vars = place_api.stat_vars(dcid)
num_stat_vars = len(stat_vars)
return Response(json.dumps(num_stat_vars), 200, mimetype='application/json')
8 changes: 4 additions & 4 deletions server/routes/api/place.py
Original file line number Diff line number Diff line change
@@ -192,23 +192,23 @@ def statsvars_route(dcid):
Returns:
A list of statistical variable dcids.
"""
return Response(json.dumps(statsvars(dcid)),
return Response(json.dumps(stat_vars(dcid)),
200,
mimetype='application/json')


@cache.memoize(timeout=3600 * 24) # Cache for one day.
def statsvars(dcid):
def stat_vars(dcid):
"""
Get all the statistical variable dcids for a place.
"""
response = fetch_data('/place/stats-var', {
response = fetch_data('/place/stat-vars', {
'dcids': [dcid],
},
compress=False,
post=False,
has_payload=False)
return response['places'][dcid].get('statsVars', [])
return response['places'][dcid].get('statVars', [])


@cache.memoize(timeout=3600 * 24) # Cache for one day.

0 comments on commit 653be6e

Please sign in to comment.