mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-25 00:28:31 -05:00
28 lines
819 B
CoffeeScript
28 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
|