<commit_before>'use strict';

import Hapi from 'hapi';
import Good from 'good';
import MongoPlug from 'mongo-plug';
import Boom from 'boom';

// Server connection
const server = new Hapi.Server();
server.connection({
  host: process.env.HOST,
  port: process.env.PORT
});
const request = require('request');

let col;

server.route({
  method: ['POST', 'GET'],
  path: '/',
  handler: function (req, rep) {
    let query = {};
    let sort = {};
    let message = {};
    console.log(req.payload.item.message.message)
    // date yesterday/today/tomorrow
    query.mealDate = '20161129';
    col.find(query).sort(sort).toArray((err, docs) => {
      if(docs.length === 0) {
        request(`${process.env.TOWERMAN_URI}?menuDate=${query.mealDate}`, (error, response, body) => {
          if (!error && response.statusCode == 200) {
            col.insertMany(JSON.parse(body).data);
          }
        });
      }
    });

    // time lunch/dinner
    query.mealTime = 1;

    // cafeteria 9F/22F
    query.cafeteriaId = '22F';

    // recommended true/false
    // query.umaiCount = { $gte: 1 };

    // healthy true/false
    // query['ingredients.healthy'] = true;

    // lowest/highest components
    sort['components.carb'] = 1;
<commit_msg>added moment<commit_after>'use strict';

import Hapi from 'hapi';
import Good from 'good';
import MongoPlug from 'mongo-plug';
import Boom from 'boom';
import * as moment from 'moment';

// Server connection
const server = new Hapi.Server();
server.connection({
  host: process.env.HOST,
  port: process.env.PORT
});
const request = require('request');

let col;

server.route({
  method: ['POST', 'GET'],
  path: '/',
  handler: function (req, rep) {
    let query = {};
    let sort = {};
    let message = {};
    // console.log(req.payload.item.message.message)
    // date yesterday/today/tomorrow
    // query.mealDate = '20161129';
    query.mealDate = moment().format('YYYYMMDD');
    col.find(query).sort(sort).toArray((err, docs) => {
      if(docs.length === 0) {
        request(`${process.env.TOWERMAN_URI}?menuDate=${query.mealDate}`, (error, response, body) => {
          if (!error && response.statusCode == 200) {
            col.insertMany(JSON.parse(body).data);
          }
        });
      }
    });

    // time lunch/dinner
    query.mealTime = 1;

    // cafeteria 9F/22F
    query.cafeteriaId = '22F';

    // recommended true/false
    // query.umaiCount = { $gte: 1 };

    // healthy true/false
    // query['ingredients.healthy'] = true;

    // lowest/highest components
    sort['components.carb'] = 1;

{'fraction_non_alphanumeric': 0.1711188540456833, 'fraction_numerical': 0.01548586914440573, 'mean_word_length': 2.7179856115107914, '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': '7166762', 'n_tokens_mistral': 899, 'n_tokens_neox': 831, 'n_words': 184}