<commit_before>'use strict';

let co   = require('co');
let cli  = require('heroku-cli-util');
let time = require('../lib/time');
let _    = require('lodash');

let empty = o => Object.keys(o).length === 0;

function displayFormation (formation) {
  formation = _.groupBy(formation, 'size');
  formation = _.map(formation, (p, size) => `${cli.color.yellow(_.sumBy(p, 'quantity'))}:${cli.color.cyan(size)}`);
  cli.log(`  Dynos: ${formation.join(' ')}`);
}

function displayErrors (metrics) {
  let errors = [];
  if (metrics.routerErrors) {
    errors = errors.concat(_.toPairs(metrics.routerErrors.data).map(e => cli.color.red(`${_.sum(e[1])} ${e[0]}`)));
  }
  if (metrics.dynoErrors) {
    metrics.dynoErrors.filter(d => d).forEach(dynoErrors => {
      errors = errors.concat(_.toPairs(dynoErrors.data).map(e => cli.color.red(`${_.sum(e[1])} ${e[0]}`)));
    });
  }
  if (errors.length > 0) cli.log(`  ${errors.join(', ')} - see details with ${cli.color.yellow('heroku apps:errors')}`);
}

function displayMetrics (metrics) {
  function rpmSparkline() {
    let sparkline = require('sparkline');
    let points = [];
    _.values(metrics.routerStatus.data).forEach(cur => {
      for (let i=0; i<cur.length; i++) {
        let j = Math.floor(i/3);
        points[j] = (points[j] || 0)+cur[i];
      }
    });
    points.pop();
    return sparkline(points) + ' last 24 hours rpm';
  }
  let ms = ''; let rpm = '';
  if (metrics.routerLatency && !empty(metrics.routerLatency.data)) {
    ms = _.pad(`${_.round(_.mean(metrics.routerLatency.data.latency_p50))} ms`, 6);
  }
  if (metrics.routerStatus && !empty(metrics.routerStatus.data)) {
    rpm = `${_.round(_.sum(_.flatten(_.values(metrics.routerStatus.data)))/24/60)} rpm ${rpmSparkline()}`;
  }
  if (rpm || ms) cli.log(`  ${cli.color.green(ms)} ${cli.color.yellow(rpm)}`);<commit_msg>disable sparklines on windows<commit_after>'use strict';

let co   = require('co');
let cli  = require('heroku-cli-util');
let time = require('../lib/time');
let _    = require('lodash');

let empty = o => Object.keys(o).length === 0;

function displayFormation (formation) {
  formation = _.groupBy(formation, 'size');
  formation = _.map(formation, (p, size) => `${cli.color.yellow(_.sumBy(p, 'quantity'))}:${cli.color.cyan(size)}`);
  cli.log(`  Dynos: ${formation.join(' ')}`);
}

function displayErrors (metrics) {
  let errors = [];
  if (metrics.routerErrors) {
    errors = errors.concat(_.toPairs(metrics.routerErrors.data).map(e => cli.color.red(`${_.sum(e[1])} ${e[0]}`)));
  }
  if (metrics.dynoErrors) {
    metrics.dynoErrors.filter(d => d).forEach(dynoErrors => {
      errors = errors.concat(_.toPairs(dynoErrors.data).map(e => cli.color.red(`${_.sum(e[1])} ${e[0]}`)));
    });
  }
  if (errors.length > 0) cli.log(`  ${errors.join(', ')} - see details with ${cli.color.yellow('heroku apps:errors')}`);
}

function displayMetrics (metrics) {
  function rpmSparkline() {
    if (process.platform === 'win32') return;
    let sparkline = require('sparkline');
    let points = [];
    _.values(metrics.routerStatus.data).forEach(cur => {
      for (let i=0; i<cur.length; i++) {
        let j = Math.floor(i/3);
        points[j] = (points[j] || 0)+cur[i];
      }
    });
    points.pop();
    return sparkline(points) + ' last 24 hours rpm';
  }
  let ms = ''; let rpm = '';
  if (metrics.routerLatency && !empty(metrics.routerLatency.data)) {
    ms = _.pad(`${_.round(_.mean(metrics.routerLatency.data.latency_p50))} ms`, 6);
  }
  if (metrics.routerStatus && !empty(metrics.routerStatus.data)) {
    rpm = `${_.round(_.sum(_.flatten(_.values(metrics.routerStatus.data)))/24/60)} rpm ${rpmSparkline()}`;
  }
  if (rpm || ms) cli.log(`  ${cli.color.green(ms)} ${cli.color.yellow(rpm)}`);
{'fraction_non_alphanumeric': 0.22171824973319104, 'fraction_numerical': 0.010138740661686232, 'mean_word_length': 3.8688311688311687, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6122489', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1352, 'n_words': 236}