<commit_before>#!/usr/bin/env node

const readline = require('readline');
const Promise = require('bluebird');
const clear = require('./clear-stdout');
const getWorklog = Promise.promisify(require('./get-worklog'));
const questions = require('./questions');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

const rlQuestion = Promise.promisify(function (question, callback) {
  rl.question(question, callback.bind(null, null));
});

Promise.each(Object.keys(questions), function (key) {
  clear();
  rl.write(questions[key].a);
  return questions[key] = rlQuestion(questions[key].q);
}).return(questions).props().then(function (result) {
  getWorklog(result)
    .then(function (res) {
      console.log(res);
    })
    .catch(err => {
      throw err;
    });

  console.log('Please wait...');
  rl.close();
});<commit_msg>Process results to return string of durations<commit_after>#!/usr/bin/env node

const readline = require('readline');
const Promise = require('bluebird');
const clear = require('./clear-stdout');
const getWorklog = Promise.promisify(require('./get-worklog'));
const questions = require('./questions');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

const rlQuestion = Promise.promisify(function (question, callback) {
  rl.question(question, callback.bind(null, null));
});

Promise.each(Object.keys(questions), function (key) {
  clear();
  rl.write(questions[key].a);
  return questions[key] = rlQuestion(questions[key].q);
}).return(questions).props().then(function (result) {
  getWorklog(result)
    .then(res => {
      let sum = 0;
      const str = res[0].reduce((accum, current) => {
        sum += current.duration;
        return accum += `${current.startDate}: ${current.duration / 3600}h\n`;
      }, '');
      return `${str}Summury: ${sum / 3600}h\n`;
    })
    .then(console.log)
    .catch(err => {
      throw err;
    });

  console.log('Please wait...');
  rl.close();
});
{'fraction_non_alphanumeric': 0.18376494023904383, 'fraction_numerical': 0.0049800796812749, 'mean_word_length': 4.125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5722985', 'n_tokens_mistral': 657, 'n_tokens_neox': 629, 'n_words': 127}