0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Synced the start date of members and MRR 'all time' charts (dashboard 5.0)

no issue

- When using 'all time' in the past, the start date of the total members/paid members chart would differ from the MRR chart. They are now synced.
- The start date is always the earliest date we have data for (MRR or member counts)
- The all time chart is minimum 90 days long
This commit is contained in:
Simon Backx 2022-04-08 10:04:42 +02:00
parent b3bb12a4ce
commit 7b12785c30

View file

@ -613,7 +613,23 @@ export default class DashboardStatsService extends Service {
let currentRangeDate;
if (days === 'all') {
currentRangeDate = data.length > 0 ? moment(data[0].date) : moment();
const MINIMUM_DAYS = 90;
currentRangeDate = moment().subtract(MINIMUM_DAYS - 1, 'days');
// Make sure all charts are synced correctly and have the same start date when choosing 'all time'
if (this.mrrStats !== null && this.mrrStats.length > 0) {
const date = moment(this.mrrStats[0].date);
if (date.toDate() < currentRangeDate.toDate()) {
currentRangeDate = date;
}
}
if (this.memberCountStats !== null && this.memberCountStats.length > 0) {
const date = moment(this.memberCountStats[0].date);
if (date.toDate() < currentRangeDate.toDate()) {
currentRangeDate = date;
}
}
} else {
currentRangeDate = moment().subtract(days - 1, 'days');
}