Skip to content

Commit 065eef7

Browse files
committed
[server-stats] allow look n month back via api
1 parent ab676c1 commit 065eef7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

plugins/server-stats/api/api.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ var plugin = {},
119119
var periodsToFetch = [],
120120
utcMoment = common.moment.utc();
121121

122-
utcMoment.subtract(2, "months");
123-
periodsToFetch.push(utcMoment.format("YYYY") + ":" + utcMoment.format("M"));
124-
utcMoment.add(2, "months");
125-
126-
utcMoment.subtract(1, "months");
127-
periodsToFetch.push(utcMoment.format("YYYY") + ":" + utcMoment.format("M"));
128-
utcMoment.add(1, "months");
122+
var monthBack = parseInt(params.qstring.months) || 3;
123+
124+
for(var i = monthBack-1; i > 0; i--){
125+
utcMoment.subtract(i, "months");
126+
periodsToFetch.push(utcMoment.format("YYYY") + ":" + utcMoment.format("M"));
127+
utcMoment.add(i, "months");
128+
}
129129

130130
periodsToFetch.push(utcMoment.format("YYYY") + ":" + utcMoment.format("M"));
131131

plugins/server-stats/tests.js

Whitespace-only changes.

0 commit comments

Comments
 (0)