Skip to content

Commit e66c538

Browse files
author
Cookiezaurs
committed
[core]Fixes for getting current "day of year" on recording.
[views] Fixes for tests
1 parent 3102dfb commit e66c538

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

api/utils/common.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,13 @@ common.getDate = function(timestamp, timezone) {
693693
* @returns {number} current day of the year
694694
*/
695695
common.getDOY = function(timestamp, timezone) {
696-
var endDate = (timestamp) ? moment.unix(timestamp * 1000) : moment();
696+
var endDate;
697+
if (timestamp && timestamp.toString().length === 13) {
698+
endDate = (timestamp) ? moment.unix(timestamp / 1000) : moment();
699+
}
700+
else {
701+
endDate = (timestamp) ? moment.unix(timestamp) : moment();
702+
}
697703

698704
if (timezone) {
699705
endDate.tz(timezone);

plugins/views/tests.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ tableResponse["30days"] = {"iTotalRecords": 0, "iTotalDisplayRecords": 0, "aaDat
2929
tableResponse["7days"] = {"iTotalRecords": 0, "iTotalDisplayRecords": 0, "aaData": [{"u": 0, "t": 0, "s": 0, "b": 0, "e": 0, "d-calc": 0, "d": 0, "n": 0, "scr-calc": 0, "scr": 0, "uvalue": 0}]};
3030
tableResponse.month = {"iTotalRecords": 0, "iTotalDisplayRecords": 0, "aaData": [{"u": 0, "t": 0, "s": 0, "b": 0, "e": 0, "d-calc": 0, "d": 0, "n": 0, "scr-calc": 0, "scr": 0, "uvalue": 0}]}; //this year
3131

32+
var userHistory = {};
3233

3334
graphResponse.hour = {};
3435
graphResponse.yesterday = {};
@@ -277,11 +278,14 @@ describe('Testing views plugin', function() {
277278
tableResponse["30days"].iTotalRecords += 1;
278279
tableResponse["30days"].iTotalDisplayRecords += 1;
279280
pushValues("30days", 0, {"u": 1, "t": 1, "s": 1, "uvalue": 1, "n": 1, "view": "testview0"});
281+
userHistory["user1"] = {};
282+
userHistory["user1"]["30days"] = true;
280283

281284
if (days_this_year > 25) {
282285
tableResponse.month.iTotalRecords += 1;
283286
tableResponse.month.iTotalDisplayRecords += 1;
284287
pushValues("month", 0, {"t": 1, "s": 1, "uvalue": 1, "u": 1, "n": 1, "view": "testview0"});
288+
userHistory["user1"]["month"] = true;
285289
}
286290
/* else {
287291
tableResponse.month.iTotalRecords = 0;
@@ -321,7 +325,13 @@ describe('Testing views plugin', function() {
321325
if (days_this_year > 1) {
322326
tableResponse.month.iTotalRecords = 1;
323327
tableResponse.month.iTotalDisplayRecords = 1;
324-
pushValues("month", 0, {"t": 1, "s": 1});
328+
if (userHistory["user1"]["month"]) {
329+
pushValues("month", 0, {"t": 1, "s": 1});
330+
}
331+
else {
332+
pushValues("month", 0, {"u": 1, "uvalue": 1, "t": 1, "s": 1, "view": "testview0"});
333+
userHistory["user1"]["month"] = true;
334+
}
325335
//tableResponse["month"]['aaData'][0]['n']=1;
326336
tableResponse.month.aaData[0].uvalue = 1;
327337
}

0 commit comments

Comments
 (0)