Skip to content

Commit d56a3c1

Browse files
authored
Merge pull request #4737 from Cookiezaurs/master
[server-stats] Passing period as 2 strings repesenting time (not timestamps) to esnure correctly selected periods
2 parents 5084a4b + 81b3d69 commit d56a3c1

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

frontend/express/public/javascripts/countly/countly.common.js

+16
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,22 @@
169169

170170
store.set("countly_date", period);
171171
};
172+
/* Returns strings representing dates, not timestamps*/
173+
countlyCommon.getPeriodAsDateStrings = function() {
174+
var array = [];
175+
if (Array.isArray(_period)) {
176+
if (countlyCommon.periodObj.currentPeriodArr && countlyCommon.periodObj.currentPeriodArr.length > 0) {
177+
var splitted = countlyCommon.periodObj.currentPeriodArr[0].split(".");
178+
array.push(splitted[2] + "-" + splitted[1] + "-" + splitted[0] + " 00:00:00");
179+
splitted = countlyCommon.periodObj.currentPeriodArr[countlyCommon.periodObj.currentPeriodArr.length - 1].split(".");
180+
array.push(splitted[2] + "-" + splitted[1] + "-" + splitted[0] + " 23:59:59");
181+
}
182+
return JSON.stringify(array);
183+
}
184+
else {
185+
return countlyCommon.getPeriodForAjax();
186+
}
187+
};
172188

173189
/**
174190
* Get currently selected period

plugins/server-stats/frontend/public/javascripts/countly.models.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
type: "GET",
1616
url: countlyCommon.API_PARTS.data.r + "/server-stats/data-points",
1717
data: {
18-
"period": countlyCommon.getPeriodForAjax(),
18+
"period": countlyCommon.getPeriodAsDateStrings(),
1919
"selected_app": options.app_id || "",
2020
},
2121
dataType: "json",
@@ -31,7 +31,7 @@
3131

3232
countlyDataPoints.punchCard = function(options) {
3333
var data = {};
34-
data.period = countlyCommon.getPeriodForAjax();
34+
data.period = countlyCommon.getPeriodAsDateStrings();
3535

3636
if (options.app_id) {
3737
data.selected_app = options.app_id;
@@ -53,7 +53,7 @@
5353

5454
countlyDataPoints.calculateTop = function(/*options*/) {
5555
var data = {};
56-
data.period = countlyCommon.getPeriodForAjax();
56+
data.period = countlyCommon.getPeriodAsDateStrings();
5757
return $.when(
5858
$.ajax({
5959
type: "GET",

0 commit comments

Comments
 (0)