diff options
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/api/metadata.py | 6 | ||||
-rw-r--r-- | gn3/db/rdf.py | 6 |
2 files changed, 4 insertions, 8 deletions
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/<symbol>", methods=["GET"]) diff --git a/gn3/db/rdf.py b/gn3/db/rdf.py index 3f4db9b..4fd47cb 100644 --- a/gn3/db/rdf.py +++ b/gn3/db/rdf.py @@ -24,24 +24,18 @@ def sparql_construct_query(query: str, endpoint: str) -> dict: def query_frame_and_compact(query: str, context: dict, endpoint: str) -> dict: """Frame and then compact the results given a context""" results = sparql_construct_query(query, endpoint) - if not results: - return {} return jsonld.compact(jsonld.frame(results, context), context) def query_and_compact(query: str, context: dict, endpoint: str) -> dict: """Compact the results given a context""" results = sparql_construct_query(query, endpoint) - if not results: - return {} return jsonld.compact(results, context) def query_and_frame(query: str, context: dict, endpoint: str) -> dict: """Frame the results given a context""" results = sparql_construct_query(query, endpoint) - if not results: - return {} return jsonld.frame(results, context) |