mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-01 23:37:43 +03:00
Replaced usage of older MRR stats endpoint with new endpoint
refs https://github.com/TryGhost/Team/issues/1470 - Correctly uses the highest value currency in the MRR graph
This commit is contained in:
parent
738dbba82a
commit
0d7ada66b3
@ -325,13 +325,26 @@ export default class DashboardStatsService extends Service {
|
||||
return;
|
||||
}
|
||||
|
||||
let statsUrl = this.ghostPaths.url.api('members/stats/mrr');
|
||||
let statsUrl = this.ghostPaths.url.api('stats/mrr');
|
||||
let stats = yield this.ajax.request(statsUrl);
|
||||
|
||||
// @todo: add proper support for all different currencies that are returned
|
||||
this.mrrStats = stats.data[0].data.map((d) => {
|
||||
return {date: d.date, mrr: d.value};
|
||||
});
|
||||
// Only show the highest value currency and filter the other ones out
|
||||
const totals = stats.meta.totals;
|
||||
let currentMax = totals[0];
|
||||
if (!currentMax) {
|
||||
// No valid data
|
||||
this.mrrStats = [];
|
||||
return;
|
||||
}
|
||||
|
||||
for (const total of totals) {
|
||||
if (total.mrr > currentMax.mrr) {
|
||||
currentMax = total;
|
||||
}
|
||||
}
|
||||
|
||||
const useCurrency = currentMax.currency;
|
||||
this.mrrStats = stats.stats.filter(d => d.currency === useCurrency);
|
||||
}
|
||||
|
||||
loadLastSeen() {
|
||||
|
Loading…
Reference in New Issue
Block a user