Skip to content

Commit

Permalink
Fix summary hint scheme for excluding elements (#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Munro authored Nov 28, 2023
1 parent 3b5815e commit 66a49a1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions emmet-api/emmet/api/routes/materials/summary/hint_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@ def generate_hints(self, query):
hints["agg_hint"] = hints["count_hint"]

if list(query.get("criteria").keys()) != ["deprecated", "builder_meta.license"]:
pure_params = [param.split(".")[0] for param in query["criteria"]]

pure_params = []
excluded_elements = False
for param, val in query["criteria"].items():
pure_param = param.split(".")[0]
pure_params.append(pure_param)
if pure_param == "composition_reduced" and val == {"$exists": False}:
excluded_elements = True


if "has_props" in pure_params:
hints["count_hint"] = {"has_props.$**": 1}
elif "composition_reduced" in pure_params:
elif "composition_reduced" in pure_params and not excluded_elements:
hints["count_hint"] = {"composition_reduced.$**": 1}
else:
for param in query["criteria"]:
if param not in ["deprecated", "builder_meta.license"]:
if param not in ["deprecated", "builder_meta.license"] and "composition_reduced" not in param:
hints["count_hint"] = {
"deprecated": 1,
"builder_meta.license": 1,
Expand Down

0 comments on commit 66a49a1

Please sign in to comment.