Skip to content

Commit

Permalink
Revert materials hint scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
munrojm committed Nov 8, 2023
1 parent 0ec549d commit e689261
Showing 1 changed file with 6 additions and 39 deletions.
45 changes: 6 additions & 39 deletions emmet-api/emmet/api/routes/materials/materials/hint_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,10 @@ class MaterialsHintScheme(HintScheme):
"""

def generate_hints(self, query):
hints = {"count_hint": {"deprecated": 1, "builder_meta.license": 1}}
hints["agg_hint"] = hints["count_hint"]
for param in query["criteria"]:
if "composition_reduced" in param:
return {"hint": {"composition_reduced.$**": 1}}
elif "nelements" in param:
return {"hint": {"nelements": 1}}

if list(query.get("criteria").keys()) != ["deprecated", "builder_meta.license"]:
for param in query["criteria"]:
if (
param
not in [
"deprecated",
"builder_meta.license",
]
and "has_props" not in param
):
hints["count_hint"] = {
"deprecated": 1,
"builder_meta.license": 1,
"formula_pretty": 1,
"material_id": 1,
param: 1,
}
hints["agg_hint"] = hints["count_hint"]
break

elif query.get("sort", {}):
for param in query["sort"]:
if param not in [
"deprecated",
"builder_meta.license",
"material_id",
"formula_pretty",
]:
hints["agg_hint"] = {
"deprecated": 1,
"builder_meta.license": 1,
"formula_pretty": 1,
"material_id": 1,
param: 1,
}

return hints
return {"hint": {}}

0 comments on commit e689261

Please sign in to comment.