Skip to content

Commit

Permalink
retain section titles in config search filtering terms
Browse files Browse the repository at this point in the history
  • Loading branch information
gsfk committed Aug 22, 2024
1 parent c7bb887 commit 76556cb
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions bento_beacon/utils/katsu_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
# -------------------------------------------------------
Expand Down

0 comments on commit 76556cb

Please sign in to comment.