mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
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:
parent
75b55e69f7
commit
16d0629de3
1 changed files with 32 additions and 4 deletions
|
@ -178,8 +178,19 @@ export default class DashboardStatsService extends Service {
|
||||||
this.memberCounts = {...this.dashboardMocks.memberCounts};
|
this.memberCounts = {...this.dashboardMocks.memberCounts};
|
||||||
return;
|
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() {
|
loadMemberCountStats() {
|
||||||
|
@ -257,8 +268,25 @@ export default class DashboardStatsService extends Service {
|
||||||
this.membersLastSeen7d = this.dashboardMocks.membersLastSeen7d;
|
this.membersLastSeen7d = this.dashboardMocks.membersLastSeen7d;
|
||||||
return;
|
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() {
|
loadPaidMembersByCadence() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue