From f193cbf8aff4e954fc427b539d68ef8ab0694e5b Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Mon, 8 Jul 2024 12:16:14 +0200 Subject: [PATCH] fix(chalice): fix wrong received filter payload --- api/schemas/schemas.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/api/schemas/schemas.py b/api/schemas/schemas.py index bf6ca56740..a5e8d6ef03 100644 --- a/api/schemas/schemas.py +++ b/api/schemas/schemas.py @@ -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")