mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-26 05:53:39 -04:00
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.count #{monthlyGrowth.toFixed(1)}%
|
||||
.col-md-5.big-stat.churn-count
|
||||
div.description Monthly Churn
|
||||
div.description Monthly Churn (cancelled / total)
|
||||
div.count #{monthlyChurn.toFixed(1)}%
|
||||
|
||||
each graph in analytics.graphs
|
||||
|
|
|
@ -129,14 +129,14 @@ module.exports = class AnalyticsSubscriptionsView extends RootView
|
|||
ended: subDayMap[day]['end'] or 0
|
||||
|
||||
@subs.sort (a, b) -> a.day.localeCompare(b.day)
|
||||
startedLastMonth = 0
|
||||
totalLastMonth = 0
|
||||
for sub, i in @subs
|
||||
@total += sub.started
|
||||
@total -= sub.ended
|
||||
@cancelled += sub.cancelled
|
||||
sub.total = @total
|
||||
startedLastMonth += sub.started if @subs.length - i < 31
|
||||
@monthlyChurn = @cancelled / startedLastMonth * 100.0 if startedLastMonth > 0
|
||||
totalLastMonth = @total if @subs.length - i is 31
|
||||
@monthlyChurn = @cancelled / 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue