diff --git a/app/templates/admin/analytics-subscriptions.jade b/app/templates/admin/analytics-subscriptions.jade index 3ed6ca864..7d98aa993 100644 --- a/app/templates/admin/analytics-subscriptions.jade +++ b/app/templates/admin/analytics-subscriptions.jade @@ -24,7 +24,7 @@ block content div.description 30 Day Total Growth div.count #{monthlyGrowth.toFixed(1)}% .col-md-5.big-stat.churn-count - div.description Monthly Churn (cancelled / total) + div.description 30 Day Churn (cancelled / total) div.count #{monthlyChurn.toFixed(1)}% each graph in analytics.graphs diff --git a/app/views/admin/AnalyticsSubscriptionsView.coffee b/app/views/admin/AnalyticsSubscriptionsView.coffee index 3ad0e16f1..571cac432 100644 --- a/app/views/admin/AnalyticsSubscriptionsView.coffee +++ b/app/views/admin/AnalyticsSubscriptionsView.coffee @@ -33,7 +33,6 @@ module.exports = class AnalyticsSubscriptionsView extends RootView context.subscriberCancelled = _.find context.subscribers, (subscriber) -> subscriber.cancel context.subscriberSponsored = _.find context.subscribers, (subscriber) -> subscriber.user?.stripe?.sponsorID context.total = @total ? 0 - context.cancelled = @cancellations?.length ? @cancelled ? 0 context.monthlyChurn = @monthlyChurn ? 0.0 context.monthlyGrowth = @monthlyGrowth ? 0.0 context.outstandingCancels = @outstandingCancels ? [] @@ -52,7 +51,6 @@ module.exports = class AnalyticsSubscriptionsView extends RootView @analytics = graphs: [] @subs = [] @total = 0 - @cancelled = 0 @monthlyChurn = 0.0 @monthlyGrowth = 0.0 @refreshDataState = 'Fetching dashboard data...' @@ -258,14 +256,15 @@ module.exports = class AnalyticsSubscriptionsView extends RootView ended: subDayMap[day]['end'] or 0 @subs.sort (a, b) -> a.day.localeCompare(b.day) + cancelledThisMonth = 0 totalLastMonth = 0 for sub, i in @subs @total += sub.started @total -= sub.ended - @cancelled += sub.cancelled sub.total = @total + cancelledThisMonth += sub.cancelled if @subs.length - i < 31 totalLastMonth = @total if @subs.length - i is 31 - @monthlyChurn = @cancelled / totalLastMonth * 100.0 if totalLastMonth > 0 + @monthlyChurn = cancelledThisMonth / totalLastMonth * 100.0 if totalLastMonth > 0 if @subs.length > 30 and @subs[@subs.length - 31].total > 0 startMonthTotal = @subs[@subs.length - 31].total endMonthTotal = @subs[@subs.length - 1].total