 exports.getGlobalStatusMetrics = ->
   filtersObject = this.request.query
   userRequesting = this.authenticated
-  results = yield metrics.fetchGlobalStatusMetrics(userRequesting, filtersObject)
+  results = yield metrics.fetchGlobalStatusMetrics userRequesting, filtersObject
   this.body = results
   return
 

exports.getChannelMetrics = (time, channelId) ->
  filtersObject = this.request.query
  userRequesting = this.authenticated
  results = yield metrics.fetchChannelMetrics(time, channelId, userRequesting, filtersObject)
  if time == 'status'
    this.body = results
  else
    this.body = []
    #format the message to show what the console expects
    i = 0
    while i < results.length
      if !results[i]._id.minute
        results[i]._id.minute = '00'
      if !results[i]._id.hour
        results[i]._id.hour = '00'
      if !results[i]._id.day
        results[i]._id.day = '1'
      this.body.push
        load: results[i].load
        avgResp: results[i].avgResp
        timestamp: moment.utc([
          results[i]._id.year
          results[i]._id.month - 1
          results[i]._id.day
          results[i]._id.hour
          results[i]._id.minute
        ]).format()
      i++
  return

exports.getGlobalLoadTimeMetrics =  ->
  filtersObject = this.request.query
  userRequesting = this.authenticated
  results = yield metrics.fetchGlobalLoadTimeMetrics userRequesting, filtersObject
  this.body = []

  for result, i in results
    this.body.push
      load: result.load
      avgResp: results[i].avgResp
      timestamp: moment.utc([
        result._id.year
        result._id.month - 1
        result._id.day
        result._id.hour
      ]).format()
  return

################################################################################################
