<commit_before>'use strict';

var times = require('../times');

var success = {
  name: 'success'
  , label: 'Weekly success'
  , pluginType: 'report'
};

function init() {
  return success;
}

module.exports = init;

success.html = function html(client) {
  var translate = client.translate;
  var ret =
     '<h1>' + translate('Weekly Success') + '</h1>'
    + '<div id="success-grid"></div>'
    ;
  return ret;
};

success.css = 
  '#success-placeholder td {'+
  '	border: 1px #ccc solid;'+
  '	margin: 0;'+
  '	padding: 1px;'+
  ' text-align:center;'+
  '}'+
  '#success-placeholder .bad {'+
  '	background-color: #fcc;'+
  '}'+

  '#success-placeholder .good {'+
  '	background-color: #cfc;'+
  '}'+

  '#success-placeholder th:first-child {'+
  '	width: 30%;'+
  '}'+
  '#success-placeholder th {'+
  '	width: 10%;'+
  '}'+
  '#success-placeholder table {'+
  '	width: 100%;'+
  '}'
  ;



success.report = function report_success(datastorage, sorteddaystoshow, options) {
  var Nightscout = window.Nightscout;
  var client = Nightscout.client;
  var translate = client.translate;

  var ss = require('simple-statistics');

  var low = parseInt(options.targetLow),
    high = parseInt(options.targetHigh);

  var data = datastorage.allstatsrecords;
    
  var now = Date.now();
  var period = 7 * times.hours(24).msecs;
  var firstDataPoint = data.reduce(function(min, record) {
      return Math.min(min, record.displayTime);
    }, Number.MAX_VALUE);
  if (firstDataPoint < 1390000000000) {
    firstDataPoint = 1390000000000;
  }
  var quarters = Math.floor((Date.now() - firstDataPoint) / period);

  var grid = $('#success-grid');
  grid.empty();
  var table = $('<table/>');

  if (quarters === 0) {
    // insufficent data
    grid.append('<p>'+translate('There is not sufficient data to run this report. Select more days.')+'</p>');
    return;
  }

  var dim = function(n) {
    var a = [];
    for (var i = 0; i < n; i++) {
      a[i]=0;
    }
    return a;
  };
  var sum = function(a) {<commit_msg>remove parseInt on targets in success report<commit_after>'use strict';

var times = require('../times');

var success = {
  name: 'success'
  , label: 'Weekly success'
  , pluginType: 'report'
};

function init() {
  return success;
}

module.exports = init;

success.html = function html(client) {
  var translate = client.translate;
  var ret =
     '<h1>' + translate('Weekly Success') + '</h1>'
    + '<div id="success-grid"></div>'
    ;
  return ret;
};

success.css = 
  '#success-placeholder td {'+
  '	border: 1px #ccc solid;'+
  '	margin: 0;'+
  '	padding: 1px;'+
  ' text-align:center;'+
  '}'+
  '#success-placeholder .bad {'+
  '	background-color: #fcc;'+
  '}'+

  '#success-placeholder .good {'+
  '	background-color: #cfc;'+
  '}'+

  '#success-placeholder th:first-child {'+
  '	width: 30%;'+
  '}'+
  '#success-placeholder th {'+
  '	width: 10%;'+
  '}'+
  '#success-placeholder table {'+
  '	width: 100%;'+
  '}'
  ;



success.report = function report_success(datastorage, sorteddaystoshow, options) {
  var Nightscout = window.Nightscout;
  var client = Nightscout.client;
  var translate = client.translate;

  var ss = require('simple-statistics');

  var low = options.targetLow,
    high = options.targetHigh;

  var data = datastorage.allstatsrecords;
    
  var now = Date.now();
  var period = 7 * times.hours(24).msecs;
  var firstDataPoint = data.reduce(function(min, record) {
      return Math.min(min, record.displayTime);
    }, Number.MAX_VALUE);
  if (firstDataPoint < 1390000000000) {
    firstDataPoint = 1390000000000;
  }
  var quarters = Math.floor((Date.now() - firstDataPoint) / period);

  var grid = $('#success-grid');
  grid.empty();
  var table = $('<table/>');

  if (quarters === 0) {
    // insufficent data
    grid.append('<p>'+translate('There is not sufficient data to run this report. Select more days.')+'</p>');
    return;
  }

  var dim = function(n) {
    var a = [];
    for (var i = 0; i < n; i++) {
      a[i]=0;
    }
    return a;
  };
  var sum = function(a) {
{'fraction_non_alphanumeric': 0.1799752781211372, 'fraction_numerical': 0.021755253399258344, 'mean_word_length': 3.218978102189781, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '7562763', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1405, 'n_words': 328}