mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 04:13:30 +03:00
Removed duplicate member count queries in admin (#19473)
no refs - member_count endpoint was queried multiple times on load - moved to collectively use the member stats service - prevented multiple tasks from being queued up to return count
This commit is contained in:
parent
be6b9e437f
commit
e27a5c1e23
@ -85,6 +85,7 @@ export default class DashboardStatsService extends Service {
|
|||||||
@service membersCountCache;
|
@service membersCountCache;
|
||||||
@service settings;
|
@service settings;
|
||||||
@service membersUtils;
|
@service membersUtils;
|
||||||
|
@service membersStats;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {?SiteStatus} Contains information on what graphs need to be shown
|
* @type {?SiteStatus} Contains information on what graphs need to be shown
|
||||||
@ -523,9 +524,8 @@ export default class DashboardStatsService extends Service {
|
|||||||
this.memberCountStats = this.dashboardMocks.memberCountStats;
|
this.memberCountStats = this.dashboardMocks.memberCountStats;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let statsUrl = this.ghostPaths.url.api('stats/member_count');
|
const stats = yield this.membersStats.fetchMemberCounts();
|
||||||
let stats = yield this.ajax.request(statsUrl);
|
|
||||||
this.memberCountStats = stats.stats.map((d) => {
|
this.memberCountStats = stats.stats.map((d) => {
|
||||||
return {
|
return {
|
||||||
...d,
|
...d,
|
||||||
|
@ -52,9 +52,13 @@ export default class MembersStatsService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetchMemberCount() {
|
fetchMemberCount() {
|
||||||
let staleData = this._lastFetchedMemberCounts && (new Date() - this._lastFetchedMemberCounts) > ONE_MINUTE;
|
// if already running, return existing promise
|
||||||
|
if (this._fetchMemberCountsTask.isRunning) {
|
||||||
|
return this._fetchMemberCountsTask.last;
|
||||||
|
}
|
||||||
|
|
||||||
// return existing stats unless data is > 1 min old
|
// return existing stats unless data is > 1 min old
|
||||||
|
let staleData = this._lastFetchedMemberCounts && (new Date() - this._lastFetchedMemberCounts) > ONE_MINUTE;
|
||||||
if (this.totalMemberCount && !this._forceRefresh && !staleData && this._fetchMemberCountsTask.last) {
|
if (this.totalMemberCount && !this._forceRefresh && !staleData && this._fetchMemberCountsTask.last) {
|
||||||
return this._fetchMemberCountsTask.last;
|
return this._fetchMemberCountsTask.last;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user