diff options
author | Munyoki Kilyungi | 2024-09-02 19:17:47 +0300 |
---|---|---|
committer | BonfaceKilz | 2024-09-05 16:39:14 +0300 |
commit | 5111b97fc058915f6dc38061fb4d2011d731657f (patch) | |
tree | 7996618d7cc0bf6208a01dc1d02480b99a8a3775 /gn3 | |
parent | 3f3d711ea04ea8b3c680557a58d174259695044d (diff) | |
download | genenetwork3-5111b97fc058915f6dc38061fb4d2011d731657f.tar.gz |
Enforce array type to "categories" and "pmids" fields.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/db/rdf/wiki.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gn3/db/rdf/wiki.py b/gn3/db/rdf/wiki.py index a208b74..d8fd8c8 100644 --- a/gn3/db/rdf/wiki.py +++ b/gn3/db/rdf/wiki.py @@ -143,4 +143,19 @@ CONSTRUCT { query, WIKI_CONTEXT, sparql_uri ) + data = results.get("data") + for result in data: + categories = result.get("categories") + if categories and isinstance(categories, str): + result["categories"] = [categories] + else: + result["categories"] = [] + pmids = result.get("pubmed_ids") + if pmids and isinstance(pmids, str): + result["pubmed_ids"] = [pmids] + elif pmids: + result["pubmed_ids"] = [int(pmid) for pmid in pmids] + else: + result["pubmed_ids"] = [] + result["version"] = int(result["version"]) return results |