From e2556ea76e10b7078f61addefc12bde3147ff94d Mon Sep 17 00:00:00 2001 From: Kraiem Taha Yassine Date: Mon, 28 Oct 2024 12:08:17 +0100 Subject: [PATCH] fix(chalice): heatmap handles empty/null url (#2691) --- api/chalicelib/core/heatmaps.py | 2 ++ api/schemas/schemas.py | 2 +- ee/api/chalicelib/core/heatmaps.py | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/api/chalicelib/core/heatmaps.py b/api/chalicelib/core/heatmaps.py index 1cfdaa833..b8ec95bee 100644 --- a/api/chalicelib/core/heatmaps.py +++ b/api/chalicelib/core/heatmaps.py @@ -9,6 +9,8 @@ logger = logging.getLogger(__name__) def get_by_url(project_id, data: schemas.GetHeatMapPayloadSchema): + if data.url is None or data.url == "": + return [] args = {"startDate": data.startTimestamp, "endDate": data.endTimestamp, "project_id": project_id, "url": data.url} constraints = ["sessions.project_id = %(project_id)s", diff --git a/api/schemas/schemas.py b/api/schemas/schemas.py index 1cee5c3af..cfe14ceec 100644 --- a/api/schemas/schemas.py +++ b/api/schemas/schemas.py @@ -1595,7 +1595,7 @@ class HeatMapFilterSchema(BaseModel): class GetHeatMapPayloadSchema(_TimedSchema): - url: str = Field(...) + url: Optional[str] = Field(...) filters: List[HeatMapFilterSchema] = Field(default=[]) click_rage: bool = Field(default=False) diff --git a/ee/api/chalicelib/core/heatmaps.py b/ee/api/chalicelib/core/heatmaps.py index 848761251..a3edb41f3 100644 --- a/ee/api/chalicelib/core/heatmaps.py +++ b/ee/api/chalicelib/core/heatmaps.py @@ -17,6 +17,8 @@ logger = logging.getLogger(__name__) def get_by_url(project_id, data: schemas.GetHeatMapPayloadSchema): + if data.url is None or data.url == "": + return [] args = {"startDate": data.startTimestamp, "endDate": data.endTimestamp, "project_id": project_id, "url": data.url} constraints = ["main_events.project_id = toUInt16(%(project_id)s)",