<commit_before>
var skiff = require('./lib/skiff'), // this must be required first
  moment = require('moment-timezone'),
  rollbar = skiff.rollbar,
  sails = skiff.sails,
  Digest = require('./lib/community/digest'),
  Promise = require('bluebird');

require('colors');

var jobs = {

  daily: function() {
    sails.log.debug('noop!');
    return Promise.resolve(null);
  },

  hourly: function() {
    var now = moment.tz('America/Los_Angeles');

    switch (now.hour()) {
      case 12:
        sails.log.debug('Sending daily digests');
        return Digest.sendDaily();
      default:
        return Promise.resolve(null);
    }
  },

  every10minutes: function() {
    sails.log.debug('noop!');
    return Promise.resolve(null);
  }

};

var runJob = Promise.method(function(name) {
  var job = jobs[name];
  if (typeof(job) !== 'function') {
    throw new Error(format('Unknown job name: "%s"', name));
  }
  sails.log.debug(format('Running %s job', name));
  return job();
});

skiff.lift({
  start: function(argv) {
    runJob(argv.interval).then(function() {
      skiff.lower();
    })
    .catch(function(err) {
      sails.log.error(err.message.red);
      rollbar.handleError(err);
      skiff.lower();
    })
  }
});
<commit_msg>remove old kue jobs regularly<commit_after>
var skiff = require('./lib/skiff'), // this must be required first
  moment = require('moment-timezone'),
  rollbar = skiff.rollbar,
  sails = skiff.sails,
  Digest = require('./lib/community/digest'),
  Promise = require('bluebird');

require('colors');

var jobs = {

  daily: function() {
    sails.log.debug('Removing old kue jobs');
    return Queue.removeOldCompletedJobs(2000);
  },

  hourly: function() {
    var now = moment.tz('America/Los_Angeles');

    switch (now.hour()) {
      case 12:
        sails.log.debug('Sending daily digests');
        return Digest.sendDaily();
      default:
        return Promise.resolve(null);
    }
  },

  every10minutes: function() {
    sails.log.debug('noop!');
    return Promise.resolve(null);
  }

};

var runJob = Promise.method(function(name) {
  var job = jobs[name];
  if (typeof(job) !== 'function') {
    throw new Error(format('Unknown job name: "%s"', name));
  }
  sails.log.debug(format('Running %s job', name));
  return job();
});

skiff.lift({
  start: function(argv) {
    runJob(argv.interval).then(function() {
      skiff.lower();
    })
    .catch(function(err) {
      sails.log.error(err.message.red);
      rollbar.handleError(err);
      skiff.lower();
    })
  }
});

{'fraction_non_alphanumeric': 0.1747534516765286, 'fraction_numerical': 0.004733727810650888, 'mean_word_length': 3.103559870550162, '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': '427136', 'n_tokens_mistral': 875, 'n_tokens_neox': 844, 'n_words': 167}