<commit_before>'use strict';

// import the express router
var router = require('express').Router();

// create model
var Dish = require('../models/model_dish');


// on routes that end in /dishes
router.route('/')

    // get upcoming dishes (GET /$apiBaseUrl/dishes)
    .get(function(req, res) {

        // today at 0:00
        var today = new Date();
        today.setHours(0,0,0,0);

        // show all dishes for current day and later
        Dish.find({'date': {'$gte': today}}).sort({date: 1, priceInternal: 1}).limit(60).exec(function(err, dishes) {
            if (err) { res.status(500).send(err); }
            res.status(200).json(dishes);
            res.end();
        });
    });


// on routes that end in /dishes/:dish_id
router.route('/:dish_id')

    // get dish with that id (GET /$apiBaseUrl/dishes/:dish_id)
    .get(function(req, res) {
        Dish.findById(req.params.dish_id, function(err, dish) {
            if (err) { res.status(500).send(err); }
            res.status(200).json(dish);
            res.end();
        });
    });


module.exports = router;<commit_msg>routes: refactor dishes<commit_after>'use strict';

// import the express router
var router = require('express').Router();

// create model
var Dish = require('../models/model_dish');


// route /dishes
router.route('/')

    // GET
    .get(function(req, res) {

        // today at 0:00
        var today = new Date();
        today.setHours(0,0,0,0);

        // get all upcoming (incl current day) entries
        Dish.find({'date': {'$gte': today}}).sort({date: 1, priceInternal: 1}).limit(60).exec(function(err, dishes) {
            if (err) { res.status(500).send(err); }
            res.status(200).json(dishes);
            res.end();
        });
    });


// route /dishes/:dish_id
router.route('/:dish_id')

    // get item by id
    .get(function(req, res) {
        Dish.findById(req.params.dish_id, function(err, dish) {
            if (err) { res.status(500).send(err); }
            res.status(200).json(dish);
            res.end();
        });
    });


module.exports = router;
{'fraction_non_alphanumeric': 0.17969494756911344, 'fraction_numerical': 0.0219256434699714, 'mean_word_length': 2.2593167701863353, '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': '2922205', 'n_tokens_mistral': 728, 'n_tokens_neox': 691, 'n_words': 149}