0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

🐛 Fixed incorrect member count on dashboard

closes https://github.com/TryGhost/Team/issues/561

In case the last event for a new member on site was before 30 day period, the count for members was showing 0 instead of the actual value. The change fixes the count to show the correct value even if there is no new recent member activity.
This commit is contained in:
Rish 2021-03-24 21:41:35 +05:30 committed by Rishabh Garg
parent 43c83c77f2
commit 803523c31d

View file

@ -112,7 +112,10 @@ export default class MembersStatsService extends Service {
const firstDateInRangeIndex = data.findIndex((val) => {
return moment(val.date).isAfter(currentRangeDate);
});
const initialDateInRangeVal = firstDateInRangeIndex > 0 ? data[firstDateInRangeIndex - 1] : null;
let initialDateInRangeVal = firstDateInRangeIndex > 0 ? data[firstDateInRangeIndex - 1] : null;
if (data.length > 0 && !initialDateInRangeVal && firstDateInRangeIndex !== 0) {
initialDateInRangeVal = data[data.length - 1];
}
let lastVal = {
paid: initialDateInRangeVal ? initialDateInRangeVal.paid : 0,
free: initialDateInRangeVal ? initialDateInRangeVal.free : 0,