mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: fix daily analytics being one day off
This commit is contained in:
@@ -148,6 +148,11 @@ Analytics.writeData = async function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Analytics.getHourlyStatsForSet = async function (set, hour, numHours) {
|
Analytics.getHourlyStatsForSet = async function (set, hour, numHours) {
|
||||||
|
// Guard against accidental ommission of `analytics:` prefix
|
||||||
|
if (!set.startsWith('analytics:')) {
|
||||||
|
set = 'analytics:' + set;
|
||||||
|
}
|
||||||
|
|
||||||
const terms = {};
|
const terms = {};
|
||||||
const hoursArr = [];
|
const hoursArr = [];
|
||||||
|
|
||||||
@@ -176,14 +181,14 @@ Analytics.getHourlyStatsForSet = async function (set, hour, numHours) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Analytics.getDailyStatsForSet = async function (set, day, numDays) {
|
Analytics.getDailyStatsForSet = async function (set, day, numDays) {
|
||||||
// Guard again accidental ommission of `analytics:` prefix
|
// Guard against accidental ommission of `analytics:` prefix
|
||||||
if (!set.startsWith('analytics:')) {
|
if (!set.startsWith('analytics:')) {
|
||||||
set = 'analytics:' + set;
|
set = 'analytics:' + set;
|
||||||
}
|
}
|
||||||
|
|
||||||
const daysArr = [];
|
const daysArr = [];
|
||||||
day = new Date(day);
|
day = new Date(day);
|
||||||
day.setDate(day.getDate() + 1); // set the date to tomorrow, because getHourlyStatsForSet steps *backwards* 24 hours to sum up the values
|
day.setDate(day.getDate() + 2); // set the date to the day after tomorrow, because getHourlyStatsForSet steps *backwards* 24 hours to sum up the values, and we also want today's values
|
||||||
day.setHours(0, 0, 0, 0);
|
day.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
while (numDays > 0) {
|
while (numDays > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user