🐛 Fixed 3D secure payment not counted as paid subscription in graph
fixes https://github.com/TryGhost/Team/issues/2644 A 3D secure payment first has a status of incomplete, then active. With the current logic, this creates 2 MemberPaidSubscriptionEvents: - `created` with mrr_delta of 0 - `active` with mrr_delta of 5 We need to also count 'active' events. And to complement that, also 'inactive' events to make sure we balance out in rare cases.
This commit is contained in:
parent
c71582877c
commit
400e1b4ab6
@ -93,27 +93,27 @@ class SubscriptionStatsService {
|
||||
`))
|
||||
.select(knex.raw(`SUM(
|
||||
CASE
|
||||
WHEN members_paid_subscription_events.type IN ('created','reactivated') AND members_paid_subscription_events.mrr_delta != 0 THEN 1
|
||||
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
|
||||
ELSE 0
|
||||
END
|
||||
) as positive_delta`))
|
||||
.select(knex.raw(`SUM(
|
||||
CASE
|
||||
WHEN members_paid_subscription_events.type IN ('canceled', 'expired') AND members_paid_subscription_events.mrr_delta != 0 THEN 1
|
||||
WHEN members_paid_subscription_events.type IN ('canceled', 'expired','inactive') AND members_paid_subscription_events.mrr_delta != 0 THEN 1
|
||||
WHEN members_paid_subscription_events.type='updated' AND price.id = from_price.id THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
) as negative_delta`))
|
||||
.select(knex.raw(`SUM(
|
||||
CASE
|
||||
WHEN members_paid_subscription_events.type IN ('created','reactivated') AND members_paid_subscription_events.mrr_delta != 0 THEN 1
|
||||
WHEN members_paid_subscription_events.type IN ('created','reactivated','active') AND members_paid_subscription_events.mrr_delta != 0 THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
) as signups`))
|
||||
.select(knex.raw(`SUM(
|
||||
CASE
|
||||
WHEN members_paid_subscription_events.type IN ('canceled', 'expired') AND members_paid_subscription_events.mrr_delta != 0 THEN 1
|
||||
WHEN members_paid_subscription_events.type IN ('canceled', 'expired','inactive') AND members_paid_subscription_events.mrr_delta != 0 THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
) as cancellations`))
|
||||
|
Loading…
Reference in New Issue
Block a user