mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Updated calculation of MRR history to use mrr column (#14481)
refs https://github.com/TryGhost/Team/issues/1518 - Uses mrr column now - Doesn't account for `cancel_at_period_end` until a migration fixes the MRR values: https://github.com/TryGhost/Ghost/pull/14480
This commit is contained in:
parent
0c72e78e6a
commit
a3215a6edf
2 changed files with 2 additions and 10 deletions
|
@ -13,15 +13,7 @@ class MrrStatsService {
|
|||
const knex = this.db.knex;
|
||||
const rows = await knex('members_stripe_customers_subscriptions')
|
||||
.select(knex.raw(`plan_currency as currency`))
|
||||
.select(knex.raw(`SUM(
|
||||
CASE WHEN plan_interval = 'year' THEN
|
||||
FLOOR(plan_amount / 12)
|
||||
ELSE
|
||||
plan_amount
|
||||
END
|
||||
) AS mrr`))
|
||||
.whereIn('status', ['active', 'unpaid', 'past_due'])
|
||||
.where('cancel_at_period_end', 0)
|
||||
.select(knex.raw(`SUM(mrr) AS mrr`))
|
||||
.groupBy('plan_currency')
|
||||
.orderBy('currency');
|
||||
|
||||
|
|
|
@ -506,7 +506,7 @@ DataGenerator.Content = {
|
|||
plan_interval: 'month',
|
||||
plan_amount: '1000',
|
||||
plan_currency: 'usd',
|
||||
mrr: 1000
|
||||
mrr: 0
|
||||
},
|
||||
{
|
||||
id: ObjectId().toHexString(),
|
||||
|
|
Loading…
Add table
Reference in a new issue