From ad5a70bb800004bbbd689ad510694433cd8d2c5d Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Fri, 15 Jul 2022 14:43:29 +0200 Subject: [PATCH 1/3] feat(chalice): fixed chalice get null-duration-session --- api/chalicelib/core/resources.py | 2 ++ ee/api/chalicelib/core/resources.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/api/chalicelib/core/resources.py b/api/chalicelib/core/resources.py index 9873bd97e..e56c0cf74 100644 --- a/api/chalicelib/core/resources.py +++ b/api/chalicelib/core/resources.py @@ -4,6 +4,8 @@ from decouple import config def get_by_session_id(session_id, project_id, start_ts, duration): with pg_client.PostgresClient() as cur: + if duration is None or (type(duration) != 'int' and type(duration) != 'float') or duration < 0: + duration = 0 delta = config("events_ts_delta", cast=int, default=60 * 60) * 1000 ch_query = """\ SELECT diff --git a/ee/api/chalicelib/core/resources.py b/ee/api/chalicelib/core/resources.py index a1f966937..71e493a4d 100644 --- a/ee/api/chalicelib/core/resources.py +++ b/ee/api/chalicelib/core/resources.py @@ -6,6 +6,8 @@ from decouple import config def get_by_session_id(session_id, project_id, start_ts, duration): with ch_client.ClickHouseClient() as ch: + if duration is None or (type(duration) != 'int' and type(duration) != 'float') or duration < 0: + duration = 0 delta = config("events_ts_delta", cast=int, default=60 * 60) * 1000 ch_query = """\ SELECT From b3c5c9f5b9ddd59acedcab959d0279b0532d0174 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Fri, 15 Jul 2022 15:12:15 +0200 Subject: [PATCH 2/3] feat(assist): default inactive live session --- utilities/utils/assistHelper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/utils/assistHelper.js b/utilities/utils/assistHelper.js index dd97a1dd9..63692f4fc 100644 --- a/utilities/utils/assistHelper.js +++ b/utilities/utils/assistHelper.js @@ -5,7 +5,7 @@ let debug = process.env.debug === "1" || false; const BASE_sessionInfo = { "pageTitle": "Page", - "active": true, + "active": false, "live": true, "sessionID": "0", "metadata": {}, From f7302c555b7cec740f5908caae9c37c40780ec48 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Fri, 15 Jul 2022 16:02:55 +0200 Subject: [PATCH 3/3] feat(assist): 2 levels sort support --- utilities/utils/helper.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/utilities/utils/helper.js b/utilities/utils/helper.js index b9c20a6f3..80b37ce27 100644 --- a/utilities/utils/helper.js +++ b/utilities/utils/helper.js @@ -158,11 +158,17 @@ const getValue = function (obj, key) { const sortPaginate = function (list, filters) { const total = list.length; list.sort((a, b) => { - const vA = getValue(a, filters.sort.key || "timestamp"); - const vB = getValue(b, filters.sort.key || "timestamp"); - return vA > vB ? 1 : vA < vB ? -1 : 0; + const tA = getValue(a, "timestamp"); + const tB = getValue(b, "timestamp"); + return tA > tB ? 1 : tA < tB ? -1 : 0; }); - + if ((filters.sort.key || "timestamp") !== "timestamp") { + list.sort((a, b) => { + const vA = getValue(a, filters.sort.key); + const vB = getValue(b, filters.sort.key); + return vA > vB ? 1 : vA < vB ? -1 : 0; + }); + } if (filters.sort.order) { list.reverse(); }