From cc478dcb535075613c809307870a863aeb3b0028 Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Mon, 28 Mar 2022 10:47:09 +0200 Subject: [PATCH] Added basic member counts chart implementation for dashboard 5 refs https://github.com/TryGhost/Team/issues/1443 A real API endpoint is now used to power the member counts chart. But it sill requires some optimizations. --- ghost/admin/app/services/dashboard-stats.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ghost/admin/app/services/dashboard-stats.js b/ghost/admin/app/services/dashboard-stats.js index 7ac58c7540..9162605399 100644 --- a/ghost/admin/app/services/dashboard-stats.js +++ b/ghost/admin/app/services/dashboard-stats.js @@ -64,6 +64,8 @@ import {tracked} from '@glimmer/tracking'; export default class DashboardStatsService extends Service { @service dashboardMocks; @service store; + @service ajax; + @service ghostPaths; /** * @type {?SiteStatus} Contains information on what graphs need to be shown @@ -214,12 +216,15 @@ export default class DashboardStatsService extends Service { // Note: that this shouldn't happen return null; } - this.memberCountStats = this.fillMissingDates(this.dashboardMocks.memberCountStats.slice(-this.chartDays), {paid: 0, free: 0, comped: 0}, this.chartDays); + this.memberCountStats = this.fillMissingDates(this.dashboardMocks.memberCountStats, {paid: 0, free: 0, comped: 0}, this.chartDays); return; } - // Normal implementation - // @todo + // @todo: we need to reuse the result of the call when we reload, because the endpoint returns all available days + // at the moment. We can reuse the result to show 7 days, 30 days, ... + let statsUrl = this.ghostPaths.url.api('members/stats/count'); + let stats = yield this.ajax.request(statsUrl); + this.memberCountStats = this.fillMissingDates(stats.data, {paid: 0, free: 0, comped: 0}, this.chartDays); } loadMrrStats() {