diff --git a/bento_beacon/utils/katsu_utils.py b/bento_beacon/utils/katsu_utils.py index 2972e67..b7e9a8e 100644 --- a/bento_beacon/utils/katsu_utils.py +++ b/bento_beacon/utils/katsu_utils.py @@ -204,36 +204,45 @@ def katsu_resources_to_beacon_resource(r): return {key: value for (key, value) in r.items() if key != "created" and key != "updated"} -# filtering terms for katsu public config search only -# possible TODOs: -# - ontology term filters (needs better ontology support) -# - filters for general phenopacket / experiment search -# - memoize? -def get_filtering_terms(): - fields_nested = get_katsu_config_search_fields().get("sections", []) - fields = [] - for f in fields_nested: - fields.extend(f["fields"]) - +def katsu_config_filtering_terms(): filtering_terms = [] - for f in fields: - filtering_term = { - "type": "alphanumeric", - "id": f["id"], - "label": f["title"], - "values": f["options"], # unimplemented proposal: https://github.com/ga4gh-beacon/beacon-v2/pull/160, - "description": f.get("description", ""), - # "modelPath": f["mapping"] unimplemented proposal: https://github.com/ga4gh-beacon/beacon-v2/issues/115 - # proposal is for path in beacon spec, so our mapping does not match exactly - # - # "scopes": scope for us is always all queryable entities in this beacon, but that can vary per beacon - # we can infer this from the endpoints / blueprints that are active - } - filtering_terms.append(filtering_term) + sections = get_katsu_config_search_fields().get("sections", []) + for section in sections: + for field in section["fields"]: + filtering_term = { + "type": "alphanumeric", + "id": field["id"], + "label": field["title"], + # longer lablel / helptext + "description": field.get("description", ""), + # + # bento internal use fields, more to come + "bento": {"section": section["section_title"]}, + # + # unimplemented proposal: https://github.com/ga4gh-beacon/beacon-v2/pull/160 + # optionally move to "bento" field if never adopted + "values": field["options"], + # + # another unimplemented proposal: https://github.com/ga4gh-beacon/beacon-v2/issues/115 + # proposal is for path in beacon spec, so our mapping does not match exactly + # "target": f["mapping"] + # + # TODO: scopes + # filter scope for us is always all queryable entities in this beacon, but that can vary per beacon + # we can infer this from the endpoints / blueprints that are active + } + filtering_terms.append(filtering_term) return filtering_terms +# memoize? +def get_filtering_terms(): + # add ontology filters here when we start supporting ontologies + # could also add filters for phenopacket and experiment queries + return katsu_config_filtering_terms() + + # ------------------------------------------------------- # utils # -------------------------------------------------------