<commit_before>var _ = require('underscore'),
    couch2pg =  require('./libs/couch2pg/index'),
    xmlforms = require('./libs/xmlforms/index');

var sleepMs = process.env.COUCH2PG_SLEEP_MINS * 60 * 1000;
if (isNaN(sleepMs)) {
  console.log('Missing time interval. Defaulting to once per hour.');
  sleepMs = 1 * 60 * 60 * 1000;
}

var loop = function () {
  console.log('Starting loop at ' + new Date());
  return couch2pg.migrate()
    .then(function() {
      console.log('Couch2pg Migration checks complete');
    })
    .then(couch2pg.import)
    .then(function () {
      console.log('Imported successfully at ' + Date());
    })
    .then(xmlforms.migrate)
    .then(function() {
      console.log('xmlforms Migration checks complete');
    })
    .then(xmlforms.extract)
    .then(function () {
      console.log('XML forms completed at ' + Date());
    })
    .catch(function(err) {
      console.error('Something went wrong', err);
    });
};

loop().then(function() {
  console.log('Next run at ' + new Date(new Date().getTime() + sleepMs));
  setInterval(loop, sleepMs);
});<commit_msg>Adding timestamp to error reporting medic/medic-webapp#2323<commit_after>var _ = require('underscore'),
    couch2pg =  require('./libs/couch2pg/index'),
    xmlforms = require('./libs/xmlforms/index');

var sleepMs = process.env.COUCH2PG_SLEEP_MINS * 60 * 1000;
if (isNaN(sleepMs)) {
  console.log('Missing time interval. Defaulting to once per hour.');
  sleepMs = 1 * 60 * 60 * 1000;
}

var loop = function () {
  console.log('Starting loop at ' + new Date());
  return couch2pg.migrate()
    .then(function() {
      console.log('Couch2pg Migration checks complete');
    })
    .then(couch2pg.import)
    .then(function () {
      console.log('Imported successfully at ' + Date());
    })
    .then(xmlforms.migrate)
    .then(function() {
      console.log('xmlforms Migration checks complete');
    })
    .then(xmlforms.extract)
    .then(function () {
      console.log('XML forms completed at ' + Date());
    })
    .catch(function(err) {
      console.error('Something went wrong at ' + Date(), err);
    });
};

loop().then(function() {
  console.log('Next run at ' + new Date(new Date().getTime() + sleepMs));
  setInterval(loop, sleepMs);
});
{'fraction_non_alphanumeric': 0.16762749445676275, 'fraction_numerical': 0.020399113082039913, 'mean_word_length': 3.3384615384615386, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '1574855', 'n_tokens_mistral': 768, 'n_tokens_neox': 730, 'n_words': 157}