codecombat/app/views/admin/AnalyticsView.coffee
Matt Lott d445024cb6 Add admin analytics page with MAUs
Includes updating analytics insert script used to inject aggregated
data into production database.
2015-11-04 10:59:10 -08:00

27 lines
819 B
CoffeeScript

RootView = require 'views/core/RootView'
template = require 'templates/admin/analytics'
utils = require 'core/utils'
module.exports = class AnalyticsView extends RootView
id: 'admin-analytics-view'
template: template
constructor: (options) ->
super options
startDay = utils.getUTCDay(-30).replace(/-/g, '')
endDay = utils.getUTCDay(-30).replace(/-/g, '')
request = @supermodel.addRequestResource 'active_users', {
url: '/db/analytics_perday/-/active_users'
data: {startDay: startDay, endDay: endDay}
method: 'POST'
success: (data) =>
@activeUsers = data
@activeUsers.sort (a, b) -> b.day.localeCompare(a.day)
@render?()
}, 0
request.load()
getRenderData: ->
context = super()
context.activeUsers = @activeUsers ? []
context