feat(chalice): fixed assist autocomplete

This commit is contained in:
Taha Yassine Kraiem 2023-01-30 16:51:29 +01:00
parent a82c1ee7d0
commit 45e4fd3771
2 changed files with 33 additions and 7 deletions

View file

@ -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)

View file

@ -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):