Add monthly growth to admin dashboard

This commit is contained in:
Matt Lott 2015-04-06 16:58:36 -07:00
parent 9d6e5fe20b
commit 51e077215e
3 changed files with 27 additions and 17 deletions

View file

@ -1,8 +1,7 @@
#admin-analytics-subscriptions-view
.big-stat
width: 25%
float: left
width: auto
.total-count
color: green
@ -12,6 +11,8 @@
color: red
.churn-count
color: orange
.growth-rate
color: green
.count
font-size: 50pt

View file

@ -8,20 +8,24 @@ block content
if total === 0
h1 Fetching subscriptions data...
else
div
.big-stat.total-count
div.description Total
div.count= total
.big-stat.remaining-count
div.description Remaining
div.count= total - cancelled
.big-stat.cancelled-count
div.description Cancelled
div.count= cancelled
.big-stat.churn-count
div.description Monthly Churn
div.count #{monthlyChurn.toFixed(2)}%
.container-fluid
.row
.col-md-5.big-stat.total-count
div.description Total
div.count= total
.col-md-5.big-stat.remaining-count
div.description Remaining
div.count= total - cancelled
.col-md-5.big-stat.cancelled-count
div.description Cancelled
div.count= cancelled
.col-md-5.big-stat.growth-rate
div.description 30 Day Total Growth
div.count #{monthlyGrowth.toFixed(1)}%
.col-md-5.big-stat.churn-count
div.description Monthly Churn
div.count #{monthlyChurn.toFixed(1)}%
each graph in analytics.graphs
.line-graph-container
each line in graph.lines

View file

@ -26,6 +26,7 @@ module.exports = class AnalyticsSubscriptionsView extends RootView
context.total = @total ? 0
context.cancelled = @cancelled ? 0
context.monthlyChurn = @monthlyChurn ? 0.0
context.monthlyGrowth = @monthlyGrowth ? 0.0
context
afterRender: ->
@ -75,7 +76,11 @@ module.exports = class AnalyticsSubscriptionsView extends RootView
@cancelled += sub.cancelled
sub.total = @total
startedLastMonth += sub.started if @subs.length - i < 31
@monthlyChurn = @cancelled / startedLastMonth * 100.0
@monthlyChurn = @cancelled / startedLastMonth * 100.0 if startedLastMonth > 0
if @subs.length > 30 and @subs[@subs.length - 31].total > 0
lastMonthTotal = @subs[@subs.length - 31].total
thisMonthTotal = @subs[@subs.length - 1].total
@monthlyGrowth = (thisMonthTotal - lastMonthTotal) / lastMonthTotal * 100
@updateAnalyticsGraphData()
@render?()
@supermodel.addRequestResource('get_subscriptions', options, 0).load()