diff --git a/ghost/admin/app/components/gh-members-chart.hbs b/ghost/admin/app/components/gh-members-chart.hbs index a18a290a9d..d543c7b15d 100644 --- a/ghost/admin/app/components/gh-members-chart.hbs +++ b/ghost/admin/app/components/gh-members-chart.hbs @@ -26,7 +26,7 @@
- {{#if this.fetchStatsTask.isRunning}} + {{#if (not this.stats)}} {{else}}

Total Members

-
{{if this.fetchStatsTask.isRunning "-" (format-number this.stats.total)}}
+
{{if (not this.stats) "-" (format-number this.stats.total)}}
{{#if (eq this.range "all-time")}} @@ -54,11 +54,11 @@ {{else}}

Signed up in the last {{this.range}} days

{{/if}} -
{{if this.fetchStatsTask.isRunning "-" (format-number this.stats.total_in_range)}}
+
{{if (not this.stats) "-" (format-number this.stats.total_in_range)}}

Signed up today

-
{{if this.fetchStatsTask.isRunning "-" (format-number this.stats.new_today)}}
+
{{if (not this.stats) "-" (format-number this.stats.new_today)}}
\ No newline at end of file diff --git a/ghost/admin/app/components/gh-members-chart.js b/ghost/admin/app/components/gh-members-chart.js index 7206f8d47e..cb6d2da488 100644 --- a/ghost/admin/app/components/gh-members-chart.js +++ b/ghost/admin/app/components/gh-members-chart.js @@ -63,18 +63,22 @@ export default Component.extend({ // Tasks ------------------------------------------------------------------- fetchStatsTask: task(function* () { + this.set('stats', null); + let stats = yield this.membersStats.fetch({days: this.selectedRange.days}); - this.set('stats', stats); + if (stats) { + this.set('stats', stats); - this.setChartOptions({ - rangeInDays: Object.keys(stats.total_on_date).length - }); + this.setChartOptions({ + rangeInDays: Object.keys(stats.total_on_date).length + }); - this.setChartData({ - dateLabels: Object.keys(stats.total_on_date), - dateValues: Object.values(stats.total_on_date) - }); + this.setChartData({ + dateLabels: Object.keys(stats.total_on_date), + dateValues: Object.values(stats.total_on_date) + }); + } }), // Internal ---------------------------------------------------------------- diff --git a/ghost/admin/app/services/members-stats.js b/ghost/admin/app/services/members-stats.js index f925298b50..be1d1481ab 100644 --- a/ghost/admin/app/services/members-stats.js +++ b/ghost/admin/app/services/members-stats.js @@ -11,11 +11,12 @@ export default class MembersStatsService extends Service { fetch({days}) { // return existing stats unless data is > 1 min old let daysChanged = days === this._days; - let staleData = this._lastFetched - new Date() > 1 * 60 * 1000; - if (!this._forceRefresh && !daysChanged && !staleData) { + let staleData = this._lastFetched && this._lastFetched - new Date() > 1 * 60 * 1000; + if (this.stats && !this._forceRefresh && !daysChanged && !staleData) { return Promise.resolve(this.stats); } + this._forceRefresh = false; this._days = days; this._lastFetched = new Date();