Fix admin dashboard monthly churn
Monthly churn = cancelled during last month / total at beginning of month
This commit is contained in:
parent
afc3689dcc
commit
dce8005169
2 changed files with 4 additions and 4 deletions
app
|
@ -24,7 +24,7 @@ block content
|
||||||
div.description 30 Day Total Growth
|
div.description 30 Day Total Growth
|
||||||
div.count #{monthlyGrowth.toFixed(1)}%
|
div.count #{monthlyGrowth.toFixed(1)}%
|
||||||
.col-md-5.big-stat.churn-count
|
.col-md-5.big-stat.churn-count
|
||||||
div.description Monthly Churn
|
div.description Monthly Churn (cancelled / total)
|
||||||
div.count #{monthlyChurn.toFixed(1)}%
|
div.count #{monthlyChurn.toFixed(1)}%
|
||||||
|
|
||||||
each graph in analytics.graphs
|
each graph in analytics.graphs
|
||||||
|
|
|
@ -129,14 +129,14 @@ module.exports = class AnalyticsSubscriptionsView extends RootView
|
||||||
ended: subDayMap[day]['end'] or 0
|
ended: subDayMap[day]['end'] or 0
|
||||||
|
|
||||||
@subs.sort (a, b) -> a.day.localeCompare(b.day)
|
@subs.sort (a, b) -> a.day.localeCompare(b.day)
|
||||||
startedLastMonth = 0
|
totalLastMonth = 0
|
||||||
for sub, i in @subs
|
for sub, i in @subs
|
||||||
@total += sub.started
|
@total += sub.started
|
||||||
@total -= sub.ended
|
@total -= sub.ended
|
||||||
@cancelled += sub.cancelled
|
@cancelled += sub.cancelled
|
||||||
sub.total = @total
|
sub.total = @total
|
||||||
startedLastMonth += sub.started if @subs.length - i < 31
|
totalLastMonth = @total if @subs.length - i is 31
|
||||||
@monthlyChurn = @cancelled / startedLastMonth * 100.0 if startedLastMonth > 0
|
@monthlyChurn = @cancelled / totalLastMonth * 100.0 if totalLastMonth > 0
|
||||||
if @subs.length > 30 and @subs[@subs.length - 31].total > 0
|
if @subs.length > 30 and @subs[@subs.length - 31].total > 0
|
||||||
startMonthTotal = @subs[@subs.length - 31].total
|
startMonthTotal = @subs[@subs.length - 31].total
|
||||||
endMonthTotal = @subs[@subs.length - 1].total
|
endMonthTotal = @subs[@subs.length - 1].total
|
||||||
|
|
Reference in a new issue