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:
Rishabh Garg 2021-02-19 18:20:41 +05:30 committed by GitHub
parent 68da78111c
commit 8a0abf7d89
2 changed files with 8 additions and 2 deletions

View File

@ -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
},

View File

@ -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>