Skip to content

Commit

Permalink
fix query string
Browse files Browse the repository at this point in the history
  • Loading branch information
shyamd committed Jan 31, 2020
1 parent 301c629 commit 123e028
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/mp_api/xas/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def search_xas(
store.connect()
query = {
"edge": edge.value if edge else None,
"absorbing_element": absorbing_element,
"absorbing_element": str(absorbing_element) if absorbing_element else None,
"chemsys": chemsys,
"elements": {"$all": [str(e) for e in elements]} if elements else None,
}
Expand All @@ -77,11 +77,12 @@ async def search_xas(
print(e)
# Return HTTP error?

query = {k: str(v) for k, v in query.items() if v}
query = {k: v for k, v in query.items() if v}

if int(limit) > 500:
limit = 500

print(query)
to_return = [
XASSearchResponse(
task_id=d["task_id"],
Expand Down Expand Up @@ -122,7 +123,7 @@ async def count_xas(
store.connect()
query = {
"edge": edge.value if edge else None,
"absorbing_element": absorbing_element,
"absorbing_element": str(absorbing_element) if absorbing_element else None,
"chemsys": chemsys,
"elements": {"$all": [str(e) for e in elements]} if elements else None,
}
Expand All @@ -134,7 +135,7 @@ async def count_xas(
print(e)
# Return HTTP error?

query = {k: str(v) for k, v in query.items() if v}
query = {k: v for k, v in query.items() if v}

return store.count(query)

Expand Down

0 comments on commit 123e028

Please sign in to comment.