<commit_before>var util = require('util');
var hits = require('./hits');
var moment = require('moment');
var duration = require('moment-duration-format');
var _ = require('lodash');

var leave = {

  collectHits: function (hits, matchDay) {

    var filteredHits = [];

    hits.forEach(function (hit){

      var isSame = moment(hit.input).isSame(matchDay, 'day');

      if (isSame) {
        filteredHits.push(hit);
      }
    });

    return filteredHits;
  },

  parseHits: function (hits) {

    var flatHits = [
      ['Input', 'Output', 'Duration', 'Interval']
    ];

    hits.forEach(function (hit){

      var input = moment(hit.input),
        output = moment(hit.output);

      var outputReferer = output.isValid() ? output : moment();

      var duration = outputReferer.diff(input, 'minutes');
      
      var interval = '-';

      var component = [
        input.format('HH:mm'),
        output.isValid() ? output.format('HH:mm') : '-',
        duration,
        interval
      ];

      flatHits.push(component);
    });

    return flatHits;
  },

  /**
   * @todo Add option to avoid headers
   */
  sumHitsDuration: function (flatHits) {

    var durations = _.pluck(flatHits, 2);

    return _.sum(durations);
  },

  formatDuration: function (minutes) {

    return moment.duration(minutes, 'minutes')
      .format('HH:mm', { trim: false });
  }
};

module.exports = leave;<commit_msg>Change some name variables improving readability<commit_after>var util = require('util');
var hits = require('./hits');
var moment = require('moment');
var duration = require('moment-duration-format');
var _ = require('lodash');

var leave = {

  collectHits: function (hits, matchDay) {

    var filteredHits = [];

    hits.forEach(function (hit){

      var isSame = moment(hit.input).isSame(matchDay, 'day');

      if (isSame) {
        filteredHits.push(hit);
      }
    });

    return filteredHits;
  },

  parseHits: function (hits) {

    var flatHits = [
      ['Input', 'Output', 'Duration', 'Interval']
    ];

    hits.forEach(function (hit){

      var input = moment(hit.input),
        output = moment(hit.output);

      var outputReferer = output.isValid() ? output : moment();

      var diff = outputReferer.diff(input, 'minutes');
      
      var interval = '-';

      var component = [
        input.format('HH:mm'),
        output.isValid() ? output.format('HH:mm') : '-',
        diff.toString(),
        interval
      ];

      flatHits.push(component);
    });

    return flatHits;
  },

  /**
   * @todo Add option to avoid headers
   */
  sumHitsDuration: function (flatHits) {

    var durations = _.pluck(flatHits, 2);

    return _.sum(durations);
  },

  formatDuration: function (minutes) {

    return moment.duration(minutes, 'minutes')
      .format('HH:mm', { trim: false });
  }
};

module.exports = leave;
{'fraction_non_alphanumeric': 0.15688329839273235, 'fraction_numerical': 0.0006988120195667365, 'mean_word_length': 2.6378653113087673, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6291426', 'n_tokens_mistral': 927, 'n_tokens_neox': 879, 'n_words': 196}