Skip to content

Commit

Permalink
fix(chalice): fix wrong received filter payload
Browse files Browse the repository at this point in the history
  • Loading branch information
tahayk committed Jul 8, 2024
1 parent f24e5f7 commit f193cbf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions api/schemas/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,14 +761,18 @@ def transform_order(cls, values):

@model_validator(mode="before")
def add_missing_attributes(cls, values):
# in case isEvent is wrong:
for f in values.get("filters"):
if EventType.has_value(f["type"]) and not f.get("isEvent"):
f["isEvent"] = True
elif FilterType.has_value(f["type"]) and f.get("isEvent"):
f["isEvent"] = False

# in case the old search payload was passed
if len(values.get("events", [])) > 0:
for v in values["events"]:
v["isEvent"] = True

# for v in values.get("filters", []):
# if v.get("isEvent") is None:
# v["isEvent"] = False
return values

@model_validator(mode="before")
Expand Down

0 comments on commit f193cbf

Please sign in to comment.