Skip to content

Commit

Permalink
Merge pull request #229 from nih-sparc/cache-get-featured-dataset-end…
Browse files Browse the repository at this point in the history
…point-response

added caching to get featured dataset endpoint
  • Loading branch information
egauzens authored Aug 26, 2024
2 parents 17abcf7 + e55982c commit 681ac24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from pennsieve.base import UnauthorizedException as PSUnauthorizedException
from PIL import Image
from requests.auth import HTTPBasicAuth
from flask_caching import Cache

from app.scicrunch_requests import create_doi_query, create_filter_request, create_facet_query, create_doi_aggregate, create_title_query, \
create_identifier_query, create_pennsieve_identifier_query, create_field_query, create_request_body_for_curies, create_onto_term_query, \
Expand All @@ -55,6 +56,7 @@
app = Flask(__name__)
# set environment variable
app.config["ENV"] = Config.DEPLOY_ENV
cache = Cache(app, config={'CACHE_TYPE': 'SimpleCache', 'CACHE_DEFAULT_TIMEOUT': 300})

CORS(app)

Expand Down Expand Up @@ -893,8 +895,8 @@ def datasets_by_project_id(project_id):
def get_featured_datasets_identifiers():
return {'identifiers': get_featured_datasets()}


@app.route("/get_featured_dataset", methods=["GET"])
@cache.cached(timeout=300)
def get_featured_dataset():
featured_dataset_id = get_featured_dataset_id_table_state(featuredDatasetIdSelectorTable)["featured_dataset_id"]
if featured_dataset_id == -1:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ oauth2client==4.1.3
algoliasearch==2.6.2
contentful==1.13.1
contentful_management==2.11.0
Flask-Caching==2.3.0

0 comments on commit 681ac24

Please sign in to comment.