 
 
     data.push({
-      _id : {"channelID": channelId },
+      _id: {"channelID": channelId},
       failed: failed,
       successful: successful,
-      processing:processing,
-      completed:completed,
-      completedWErrors:completedWErrors
+      processing: processing,
+      completed: completed,
+      completedWErrors: completedWErrors
     });
 
 
   } else {
 
-        path = render_url + ".count,'1day'))&from=-7days&format=json";
-        path += "&target=transformNull(summarize(stats.timers." + domain + ".channels." + channelId + ".sum,'1day','avg'))";
+    path = render_url + ".count,'1day'))&from=-7days&format=json";
+    path += "&target=transformNull(summarize(stats.timers." + domain + ".channels." + channelId + ".sum,'1day','avg'))";
     var raw = yield exports.fetchData(path);
     var i = 0;
     _.forEach(raw.data, function (item) {

  return data;
}`

exports.fetchData = fetchData

exports.fetcGlobalStatusMetrics = `function *(allowedIds) {
  var filtersObject = this.request.query;
  var userRequesting = this.authenticated,
    path = '',
    results = {},
    final = {};
  allowedIds = allowedIds.length > 0 ? allowedIds : yield metrics.getAllowedChannelIDs(userRequesting)
  var data = []
  var status_array = ['Processing', 'Failed', 'Completed', 'Successful', 'Completed with error(s)']

  for (var j = 0; j < allowedIds.length; j++) {
    var render_url = "/render?target=transformNull(summarize(stats.counters." + domain + ".channels." + allowedIds[j]
    for (i = 0; i < status_array.length; i++) {
      path = render_url + ".statuses." + status_array[i] + ".count,'1week'))&from=-1days&format=json";
      results[status_array[i]] = yield exports.fetchData(path);
      final[status_array[i]] = 'data' in results[status_array[i]] ? results[status_array[i]].data[0][0] : 0;

    }

    data.push({
      _id: {"channelID": allowedIds[j]},
      failed: final.Failed,
      successful: final.Successful,
      processing: final.Processing,
      completed: final.Completed,
      completedWErrors: final['Completed with error(s)']
    });
  }

