 metrics = require "../metrics"
 logger = require "winston"
 co = require "co"
+
+statusArray = ['Processing', 'Failed', 'Completed', 'Successful', 'Completed with error(s)']
 
 # Overall Metrics
 

}`

exports.retrieveChannelMetrics = `function *(type, channelId) {
  var statusArray = ['Processing', 'Failed', 'Completed', 'Successful', 'Completed with error(s)'];
  var renderUrl = "/render?target=transformNull(summarize(stats.counters." + domain + ".channels." + channelId
  var path = '';
  var total = {};

# Retrives Global Status Metrics from the StatsD API

exports.fetchGlobalStatusMetrics = `function *(allowedIds) {
  allowedIds = allowedIds.length > 0 ? allowedIds : yield metrics.getAllowedChannelIDs(this.authenticated);

  var data = allowedIds.map(function(channelId) {
    var total = {};
    var renderUrl = '/render?target=transformNull(summarize(stats.counters.' + domain + '.channels.' + channelId;

    statusArray.forEach(co.wrap(function*(statusType) {
      var path = renderUrl + '.statuses.' + statusType + '.count,\'1day\'))&format=json';
      var result = yield exports.fetchData(path);
      if (result && result.data) {
        total[statusType] = result.data[1][0];
      } else {
        total[statusType] = 0;
      }
    }));

    return {
      _id: {channelID: channelId},
      failed: total.Failed,
      successful: total.Successful,
      processing: total.Processing,
      completed: total.Completed,
      completedWErrors: total['Completed with error(s)']
    };
  });

  return this.body = data;
}`

exports.retrieveAverageLoadTimePerHour = `function *(type) {
