From 10ac8371cf216e800db3323f94287b58f522aade Mon Sep 17 00:00:00 2001 From: ayasayadi1 Date: Mon, 29 Apr 2024 14:20:34 +0000 Subject: [PATCH 1/3] changed formatSecond to show decimals --- .../public/javascripts/countly/countly.common.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/express/public/javascripts/countly/countly.common.js b/frontend/express/public/javascripts/countly/countly.common.js index c5611b8239a..4c73e2b40ff 100644 --- a/frontend/express/public/javascripts/countly/countly.common.js +++ b/frontend/express/public/javascripts/countly/countly.common.js @@ -4526,7 +4526,7 @@ * @example trimTo = 2, "Xh Xm Xs" result will be trimmed to "Xh Xm" */ countlyCommon.formatSecond = function(second, trimTo = 5) { - var timeLeft = parseInt(second); + var timeLeft = parseFloat(second); var dict = [ {k: 'year', v: 31536000}, {k: 'day', v: 86400}, @@ -4537,7 +4537,13 @@ var result = {year: 0, day: 0, hour: 0, minute: 0, second: 0}; var resultStrings = []; for (var i = 0; i < dict.length && resultStrings.length < 3; i++) { - result[dict[i].k] = Math.floor(timeLeft / dict[i].v); + if (dict[i].k === "second") { + //round to 1 decimal + result[dict[i].k] = Math.round(timeLeft / dict[i].v * 10) / 10; + } + else { + result[dict[i].k] = Math.floor(timeLeft / dict[i].v); + } timeLeft = timeLeft % dict[i].v; if (result[dict[i].k] > 0) { if (result[dict[i].k] === 1) { From 19e7a621ed601af896b8a3e00196b1690a5b4252 Mon Sep 17 00:00:00 2001 From: ayasayadi1 Date: Tue, 30 Apr 2024 09:56:43 +0000 Subject: [PATCH 2/3] set avg duration to 0 if smaller than 0.1s --- .../public/core/events/javascripts/countly.details.models.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/express/public/core/events/javascripts/countly.details.models.js b/frontend/express/public/core/events/javascripts/countly.details.models.js index 7ab10683e8b..6f193b854e3 100644 --- a/frontend/express/public/core/events/javascripts/countly.details.models.js +++ b/frontend/express/public/core/events/javascripts/countly.details.models.js @@ -11,7 +11,8 @@ for (var i = 0; i < chartData.length; i++) { graphData[0].push(chartData[i].c ? chartData[i].c : 0); graphData[1].push(chartData[i].s ? chartData[i].s : 0); - graphData[2].push(chartData[i].dur ? chartData[i].dur / (chartData[i].c || 1) : 0); + let avgDur = (chartData[i].dur || 0) / (chartData[i].c || 1); + graphData[2].push(avgDur < 0.1 ? 0 : avgDur); if (chartData[i].c) { count += chartData[i].c; } From 7828c810b8171b2edde43cbd0bccc6144d896909 Mon Sep 17 00:00:00 2001 From: ayasayadi1 Date: Tue, 30 Apr 2024 09:57:28 +0000 Subject: [PATCH 3/3] ignore values smaller than 0.1s --- .../express/public/javascripts/countly/countly.common.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/express/public/javascripts/countly/countly.common.js b/frontend/express/public/javascripts/countly/countly.common.js index 4c73e2b40ff..544fbd29e0e 100644 --- a/frontend/express/public/javascripts/countly/countly.common.js +++ b/frontend/express/public/javascripts/countly/countly.common.js @@ -4538,8 +4538,12 @@ var resultStrings = []; for (var i = 0; i < dict.length && resultStrings.length < 3; i++) { if (dict[i].k === "second") { - //round to 1 decimal - result[dict[i].k] = Math.round(timeLeft / dict[i].v * 10) / 10; + if (timeLeft < 0.1) { + result.second = 0; + } + else { + result.second = Math.round(timeLeft * 10) / 10; + } } else { result[dict[i].k] = Math.floor(timeLeft / dict[i].v);