<commit_before>/*global define*/
define('app/operating-system', ['moment', 'lodash', 'd3', 'TelemetryPromises', 'DevToolsMetrics', 'LatestVersions'],
function(moment, _, d3, T, DevToolsMetrics, LatestVersions) {

  var metric = 'DEVTOOLS_OS_ENUMERATED_PER_USER';
  var options = { sanitized: true };

  var ID = 'devtools-operating-system-chart';
  var chart = {
    title: 'Evolution of the DevTools Operating Systems (pre-release channels)',
    description: 'Telemetry numbers report the type of operating system according to our pre-defined buckets.',
    width: 335,
    height: 320,
    left: 60,
    legend_target: '#' + ID + '-legend'
  };
  var OSES = {
    0:'Windows XP',
    1:'Windows Vista',
    2:'Windows 7',
    3:'Windows 8',
    4:'Windows 8.1',
    5:'OSX',
    6:'Linux',
    7:'Windows 10',
    8:'reserved',
    9:'reserved',
    10:'reserved',
    11:'reserved',
    12:'other',
    13:'unknown'
  }
  function evolutionMap(evolutions) {
    console.log('evolutionMap', evolutions);
    // map the data into the values we need
    // histogram, index, date
    return _.flatten(evolutions.map((h, i, date) => {
      // values of less than 10 are not useful at all
      return _.filter(h.values, (v) => (v > 10)).map((v, i) => {
        return {
          os: OSES[i],
          value: v,
          date: date
        };
      })
    }));
  }

  DevToolsMetrics.line(ID, chart);

  LatestVersions.getLatestVersion().then((versions) => {
    _.remove(versions, { channel: 'release' });
    Promise.all(versions.map((target) => {
      return T.getEvolutions(target.channel, target.versions, metric, options).
              then((evolutions) => {
                console.log('evolutions', evolutions);
                return T.reduceEvolutions(evolutions);
              });
    })).then((evolutions) => {
      console.log('evolutions2', evolutions);
      return T.reduceEvolutions(evolutions);
    }).then((evolutions) => {
      var map = evolutionMap(evolutions);
      console.log('map', map);
      return map;
    }).then((data) => {
      var grouped = _.groupBy(data, 'os');
      chart.legend = _.keys(grouped);
      return _.values(grouped);
    })
    .then((data) => {
      chart.data = data;
      console.log('data', data);
      DevToolsMetrics.line(ID, chart);
    });
  });

}); // end define<commit_msg>remove all the excess console logs<commit_after>/*global define*/
define('app/operating-system', ['moment', 'lodash', 'd3', 'TelemetryPromises', 'DevToolsMetrics', 'LatestVersions'],
function(moment, _, d3, T, DevToolsMetrics, LatestVersions) {

  var metric = 'DEVTOOLS_OS_ENUMERATED_PER_USER';
  var options = { sanitized: true };

  var ID = 'devtools-operating-system-chart';
  var chart = {
    title: 'Evolution of the DevTools Operating Systems (pre-release channels)',
    description: 'Telemetry numbers report the type of operating system according to our pre-defined buckets.',
    width: 335,
    height: 320,
    left: 60,
    legend_target: '#' + ID + '-legend'
  };
  var OSES = {
    0:'Windows XP',
    1:'Windows Vista',
    2:'Windows 7',
    3:'Windows 8',
    4:'Windows 8.1',
    5:'OSX',
    6:'Linux',
    7:'Windows 10',
    8:'reserved',
    9:'reserved',
    10:'reserved',
    11:'reserved',
    12:'other',
    13:'unknown'
  }
  function evolutionMap(evolutions) {
    // map the data into the values we need
    // histogram, index, date
    return _.flatten(evolutions.map((h, i, date) => {
      // values of less than 10 are not useful at all
      return _.filter(h.values, (v) => (v > 10)).map((v, i) => {
        return {
          os: OSES[i],
          value: v,
          date: date
        };
      })
    }));
  }

  DevToolsMetrics.line(ID, chart);

  LatestVersions.getLatestVersion().then((versions) => {
    _.remove(versions, { channel: 'release' });
    Promise.all(versions.map((target) => {
      return T.getEvolutions(target.channel, target.versions, metric, options).
              then((evolutions) => T.reduceEvolutions(evolutions));
    })).then((evolutions) => T.reduceEvolutions(evolutions)
    ).then((evolutions) => evolutionMap(evolutions)
    ).then((data) => {
      var grouped = _.groupBy(data, 'os');
      chart.legend = _.keys(grouped);
      return _.values(grouped);
    })
    .then((data) => {
      chart.data = data;
      DevToolsMetrics.line(ID, chart);
    });
  });

}); // end define
{'fraction_non_alphanumeric': 0.16235827664399094, 'fraction_numerical': 0.01746031746031746, 'mean_word_length': 2.7895189003436425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '5752430', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1386, 'n_words': 328}