From 45e4fd37718bf4106388d715de87a634e719d88a Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Mon, 30 Jan 2023 16:51:29 +0100 Subject: [PATCH] feat(chalice): fixed assist autocomplete --- api/chalicelib/core/assist.py | 26 ++++++++++++++++++++++++++ api/schemas.py | 14 +++++++------- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/api/chalicelib/core/assist.py b/api/chalicelib/core/assist.py index 7cc947395..4d1b7f636 100644 --- a/api/chalicelib/core/assist.py +++ b/api/chalicelib/core/assist.py @@ -181,6 +181,8 @@ def autocomplete(project_id, q: str, key: str = None): except: print("couldn't get response") return {"errors": ["Something went wrong wile calling assist"]} + for r in results: + r["type"] = __change_keys(r["type"]) return {"data": results} @@ -262,3 +264,27 @@ def session_exists(project_id, session_id): except: print("couldn't get response") return False + + +def __change_keys(key): + return { + "PAGETITLE": schemas.LiveFilterType.page_title, + "ACTIVE": "active", + "LIVE": "live", + "SESSIONID": schemas.LiveFilterType.session_id, + "METADATA": schemas.LiveFilterType.metadata, + "USERID": schemas.LiveFilterType.user_id, + "USERUUID": schemas.LiveFilterType.user_UUID, + "PROJECTKEY": "projectKey", + "REVID": schemas.LiveFilterType.rev_id, + "TIMESTAMP": "timestamp", + "TRACKERVERSION": schemas.LiveFilterType.tracker_version, + "ISSNIPPET": "isSnippet", + "USEROS": schemas.LiveFilterType.user_os, + "USERBROWSER": schemas.LiveFilterType.user_browser, + "USERBROWSERVERSION": schemas.LiveFilterType.user_browser_version, + "USERDEVICE": schemas.LiveFilterType.user_device, + "USERDEVICETYPE": schemas.LiveFilterType.user_device_type, + "USERCOUNTRY": schemas.LiveFilterType.user_country, + "PROJECTID": "projectId" + }.get(key.upper(), key) diff --git a/api/schemas.py b/api/schemas.py index 0c4fdde77..bc27b8943 100644 --- a/api/schemas.py +++ b/api/schemas.py @@ -1163,13 +1163,13 @@ class LiveFilterType(str, Enum): user_anonymous_id = FilterType.user_anonymous_id rev_id = FilterType.rev_id platform = FilterType.platform - page_title = "PAGETITLE" - session_id = "SESSIONID" - metadata = "METADATA" - user_UUID = "USERUUID" - tracker_version = "TRACKERVERSION" - user_browser_version = "USERBROWSERVERSION" - user_device_type = "USERDEVICETYPE" + page_title = "pageTitle" + session_id = "sessionId" + metadata = FilterType.metadata, + user_UUID = "userUuid" + tracker_version = "trackerVersion" + user_browser_version = "userBrowserVersion" + user_device_type = "userDeviceType" class LiveSessionSearchFilterSchema(BaseModel):