 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.getGlobalLoadTimeMetrics =  ->
  filtersObject = this.request.query
  userRequesting = this.authenticated
  results = yield metrics.fetchGlobalLoadTimeMetrics(userRequesting, filtersObject)
  this.body = []
  i = 0
  while i < results.length
    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
      ]).format()
    i++
  return

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

exports.getChannelMetrics = (time, channelId) ->
  filtersObject = this.request.query
  userRequesting = this.authenticated
  results = yield metrics.fetchChannelMetrics time, channelId, userRequesting, filtersObject
  if time is 'status'
    this.body = results
  else
    this.body = []
    #format the message to show what the console expects

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

  return
