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

View file

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

View file

@ -26,6 +26,7 @@ module.exports = class AnalyticsSubscriptionsView extends RootView
context.total = @total ? 0 context.total = @total ? 0
context.cancelled = @cancelled ? 0 context.cancelled = @cancelled ? 0
context.monthlyChurn = @monthlyChurn ? 0.0 context.monthlyChurn = @monthlyChurn ? 0.0
context.monthlyGrowth = @monthlyGrowth ? 0.0
context context
afterRender: -> afterRender: ->
@ -75,7 +76,11 @@ module.exports = class AnalyticsSubscriptionsView extends RootView
@cancelled += sub.cancelled @cancelled += sub.cancelled
sub.total = @total sub.total = @total
startedLastMonth += sub.started if @subs.length - i < 31 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() @updateAnalyticsGraphData()
@render?() @render?()
@supermodel.addRequestResource('get_subscriptions', options, 0).load() @supermodel.addRequestResource('get_subscriptions', options, 0).load()