<commit_before>var express    = require('express');
var bodyParser = require('body-parser');
var route      = require('./route');
var app        = express();

var Annict = require('annict').default;
var annict = new Annict();

app.set('views', __dirname+'/views');
app.set('view engine', 'pug');
app.use(bodyParser.json());
app.use('/static', express.static(__dirname+'/../public'));
app.use(route);



var mongoose = require('mongoose');
mongoose.connect(process.env.MONGODB_URI);

var models = {};
models.User = mongoose.model('User', require('./models/user'));

app.set('models', models);


var CronJob = require('cron').CronJob;
const BATCH_INTERBAL = process.env.BATCH_INTERBAL;

const User = models.User;

try {
new CronJob(`*/5 * * * * *`, function() {
  User.find({}, function(err, users) {
    console.log(users);
    users.forEach(user => {
      annict.Me.Work.get({
        access_token: user.access_token,
        filter_status: 'watching',
        per_page: 10
      })
      .then(response => {
        user.watching = response.works;
        user.save();
        console.log('update');
      });
    });
  });

}, function() {}, true, 'Asia/Tokyo');
}
catch(ex) {
  console.log(ex);
}

app.listen(process.env.PORT || 3000);<commit_msg>insert var to app as config<commit_after>var express    = require('express');
var bodyParser = require('body-parser');
var route      = require('./route');
var app        = express();

app.set('views', __dirname+'/views');
app.set('view engine', 'pug');
app.use(bodyParser.json());
app.use('/static', express.static(__dirname+'/../public'));
app.use(route);

const config = {
  MONGODB_URI: process.env.MONGODB_URI,
  ANNICT_FETCH_INTERBAL: process.env.ANNICT_FETCH_INTERBAL
  CLIENT_ID: process.env.CLIENT_ID,
  CLIENT_SECRET: process.env.CLIENT_SECRET,
  REDIRECT_URI: process.env.REDIRECT_URI,
};
app.set('config', config);

var Annict = require('annict').default;
var annict = new Annict();
app.set('middlewares', {
  annict
});

var mongoose = require('mongoose');
var models = {};
mongoose.connect(config.MONGODB_URI);
const User = models.User = mongoose.model('User', require('./models/user'));
app.set('models', models);


/**
 * Noe-Cron Job to fetch new data for all user
 */
const CronJob = require('cron').CronJob;
try {
  new CronJob(`* */5 * * * *`, function() {
    User.find({}, function(err, users) {
      users.forEach(user => {
        annict.Me.Work.get({
          access_token: user.access_token,
          filter_status: 'watching',
          per_page: 10
        })
        .then(response => {
          user.watching = response.works;
          user.save();
        });
      });
    });
  },
  () => {
    console.log('cron job finished');
  },
  true,
  'Asia/Tokyo');
}
catch(ex) {
  console.log(ex);
}

module.exports = app;
{'fraction_non_alphanumeric': 0.1875222816399287, 'fraction_numerical': 0.0035650623885918, 'mean_word_length': 3.405023547880691, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '5348581', 'n_tokens_mistral': 973, 'n_tokens_neox': 956, 'n_words': 178}