🐛 Fixed free trials not visible in paid subscriptions graph

fixes https://github.com/TryGhost/Team/issues/2607

When a free trial converts to a paid subscription, and increases the MRR, it just creates a 'updated' paid subscription event.

To fix this, we need to count updated events that didn't change plan but do have a positive MRR. As an extension we could also check if the MRR change matches the expected MRR for the corresponsing Stripe plan, but that requires a more complex condition check (because for yearly subscriptions we need to convert to monthly), I don't think that is required here.
This commit is contained in:
Simon Backx 2023-03-09 15:28:06 +01:00 committed by Simon Backx
parent 400e1b4ab6
commit db717f446f

View File

@ -95,6 +95,7 @@ class SubscriptionStatsService {
CASE
WHEN members_paid_subscription_events.type IN ('created','reactivated','active') AND members_paid_subscription_events.mrr_delta != 0 THEN 1
WHEN members_paid_subscription_events.type='updated' AND price.id = to_price.id THEN 1
WHEN members_paid_subscription_events.type='updated' AND members_paid_subscription_events.from_plan = members_paid_subscription_events.to_plan AND members_paid_subscription_events.mrr_delta > 0 THEN 1
ELSE 0
END
) as positive_delta`))
@ -108,6 +109,7 @@ class SubscriptionStatsService {
.select(knex.raw(`SUM(
CASE
WHEN members_paid_subscription_events.type IN ('created','reactivated','active') AND members_paid_subscription_events.mrr_delta != 0 THEN 1
WHEN members_paid_subscription_events.type='updated' AND members_paid_subscription_events.from_plan = members_paid_subscription_events.to_plan AND members_paid_subscription_events.mrr_delta > 0 THEN 1
ELSE 0
END
) as signups`))