mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
Updated mrr stats on dashboard (#1847)
refs https://github.com/TryGhost/Team/issues/469 - Adds basic percentage growth stat for mrr on dashboard - Adds base data for mrr chart in case of no mrr stats
This commit is contained in:
parent
68da78111c
commit
8a0abf7d89
@ -50,13 +50,19 @@ export default class DashboardController extends Controller {
|
||||
this.membersStats.fetchMRR().then((stats) => {
|
||||
this.events.loading = false;
|
||||
|
||||
const currencyStats = stats[0];
|
||||
let currencyStats = stats[0] || {
|
||||
data: [],
|
||||
currency: 'usd'
|
||||
};
|
||||
if (currencyStats) {
|
||||
currencyStats.data = this.membersStats.fillDates(currencyStats.data) || {};
|
||||
const dateValues = Object.values(currencyStats.data).map(val => val / 100);
|
||||
const currentMRR = dateValues.length ? dateValues[dateValues.length - 1] : 0;
|
||||
const rangeStartMRR = dateValues.length ? dateValues[0] : 0;
|
||||
const percentChange = rangeStartMRR !== 0 ? ((currentMRR - rangeStartMRR) / rangeStartMRR) * 100 : 0.0;
|
||||
this.mrrStats.data = {
|
||||
current: `${getSymbol(currencyStats.currency)}${currentMRR}`,
|
||||
percentChange,
|
||||
options: {
|
||||
rangeInDays: 30
|
||||
},
|
||||
|
@ -16,7 +16,7 @@
|
||||
<div class="gh-dashboard-summary">
|
||||
{{#if this.mrrStats.data}}
|
||||
<div class="data">{{this.mrrStats.data.current}}</div>
|
||||
<div class="growth">0.0%</div>
|
||||
<div class="growth">{{this.mrrStats.data.percentChange}}%</div>
|
||||
{{else}}
|
||||
<div class="data">$0</div>
|
||||
<div class="growth">0.0%</div>
|
||||
|
Loading…
Reference in New Issue
Block a user