Added last seen and member count stats from real API in dashboard 5

refs https://github.com/TryGhost/Team/issues/1443
This commit is contained in:
Simon Backx 2022-03-28 09:54:21 +02:00
parent 75b55e69f7
commit 16d0629de3

View File

@ -178,8 +178,19 @@ export default class DashboardStatsService extends Service {
this.memberCounts = {...this.dashboardMocks.memberCounts};
return;
}
// Normal implementation
// @todo
// @todo We need to have way to reduce the total number of API requests
const paidResult = yield this.store.query('member', {limit: 1, filter: 'status:paid'});
const paid = paidResult.meta.pagination.total;
const freeResult = yield this.store.query('member', {limit: 1, filter: 'status:-paid'});
const free = freeResult.meta.pagination.total;
this.memberCounts = {
total: paid + free,
paid,
free
};
}
loadMemberCountStats() {
@ -257,8 +268,25 @@ export default class DashboardStatsService extends Service {
this.membersLastSeen7d = this.dashboardMocks.membersLastSeen7d;
return;
}
// Normal implementation
// @todo
// @todo We need to have way to reduce the total number of API requests
const start30d = new Date(Date.now() - 30 * 3600 * 1000);
const start7d = new Date(Date.now() - 7 * 3600 * 1000);
let extraFilter = '';
if (this.lastSeenFilterStatus === 'paid') {
extraFilter = '+status:paid';
} else if (this.lastSeenFilterStatus === 'free') {
extraFilter = '+status:-paid';
}
// todo: filter by status here
const result30d = yield this.store.query('member', {limit: 1, filter: 'last_seen_at:>' + start30d.toISOString() + extraFilter});
this.membersLastSeen30d = result30d.meta.pagination.total;
const result7d = yield this.store.query('member', {limit: 1, filter: 'last_seen_at:>' + start7d.toISOString() + extraFilter});
this.membersLastSeen7d = result7d.meta.pagination.total;
}
loadPaidMembersByCadence() {