From 852de97b222ddf914ec404dfdb7d9a4965dd7d7f Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Mon, 26 Aug 2024 12:42:55 +0300 Subject: If there's no data, return a 404. * gn3/api/metadata.py (get_wiki_entries): Return an empty {} when there's no data. * gn3/db/rdf.py (query_frame_and_compact): Delete check for empty results. Instead just return the context as is. (query_and_compact): Ditto. (query_and_frame): Ditto. Signed-off-by: Munyoki Kilyungi --- gn3/api/metadata.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gn3/api') diff --git a/gn3/api/metadata.py b/gn3/api/metadata.py index 02fb721..f51616e 100644 --- a/gn3/api/metadata.py +++ b/gn3/api/metadata.py @@ -405,13 +405,15 @@ def get_wiki_entries(symbol): response = get_wiki_entries_by_symbol( symbol=symbol, sparql_uri=current_app.config.get("SPARQL_ENDPOINT")) - if not response.get("data"): + data = response.get("data") + if not data: + data = {} status_code = 404 if content_type == "application/ld+json": response = make_response(response) response.headers["Content-Type"] = "application/ld+json" return response, status_code - return jsonify(response.get("data")), status_code + return jsonify(data), status_code @metadata.route("/genewikis/ncbi/", methods=["GET"]) -- cgit v1.2.3