Skip to content

Commit

Permalink
Update cache key for stat var search POSTs (#4537)
Browse files Browse the repository at this point in the history
Quick fix to follow up
#4534 and unblock the
website release. For the future it would be nice to wrap @cache.cached
in a custom decorator that we can use everywhere which takes care of
passing default params and making sure post body is in the cache key.
  • Loading branch information
hqpho authored Aug 5, 2024
1 parent dc78ff5 commit 412d0bf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/routes/shared_api/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from server.lib import fetch
from server.lib import shared
from server.lib.cache import cache
import server.lib.util as lib_util
from server.routes import TIMEOUT
import server.services.datacommons as dc

Expand Down Expand Up @@ -99,7 +100,9 @@ def stat_var_property():


@bp.route('/stat-var-search', methods=('GET', 'POST'))
@cache.cached(timeout=TIMEOUT, query_string=True)
@cache.cached(timeout=TIMEOUT,
query_string=True,
make_cache_key=lib_util.post_body_cache_key)
def search_statvar():
"""Gets the statvars and statvar groups that match the tokens in the query."""
if request.method == 'GET':
Expand Down

0 comments on commit 412d0bf

Please sign in to comment.