<commit_before>/**
 * 订餐控制器
 */
var validator = require('validator');
var EventProxy = require('eventproxy');
var OrderProxy = require('../proxy').Order;
var OrderModel = require('../models').Order;
var tools = require('../common/tools');

/**
 * 首页，按日期查询当日记录
 * @author giscafer
 * @version 1.0
 * @date    2016-01-02T12:11:21+0800
 */
exports.index = function (req, res, next) {
    var queryDate = req.params.qdate;
    if (!queryDate) return;
    //查询过滤
    var query = {
        "$and": [{
            "create_at": {
                "$gt": queryDate + " 0:0:0"
            }
        }, {
                "create_at": {
                    "$lt": queryDate + " 23:59:59"
                }
            }]
    };
    OrderProxy.getOrdersByQuery(query, null, function (err, orders) {
        if (err) {
            return next(err);
        }
        res.send({
            data: orders
        });
    });
};
exports.showEdit = function (req, res, next) {
    var order_id = req.params.oid;
    if (order_id) {
        OrderProxy.getOrderById(order_id, function (err, order) {
            if (!order) {
                res.render404('此话题不存在或已被删除。');
                return;
            }
            if (String(order.user_id) === String(req.session.user._id) || req.session.user.is_admin) {
                res.render('order/edit', {
                    action: 'edit',
                    title: '编辑订餐',
                    order_id: order._id,
                    dish_name: order.dish_name,
                    dish_price: order.dish_price,
                    ispack: order.ispack,<commit_msg>解决IE get请求订餐记录缓存问题<commit_after>/**
 * 订餐控制器
 */
var validator = require('validator');
var EventProxy = require('eventproxy');
var OrderProxy = require('../proxy').Order;
var OrderModel = require('../models').Order;
var tools = require('../common/tools');

/**
 * 首页，按日期查询当日记录
 * @author giscafer
 * @version 1.0
 * @date    2016-01-02T12:11:21+0800
 */
exports.index = function (req, res, next) {
    var queryDate = req.params.qdate;
    if (!queryDate) return;
    //查询过滤
    var query = {
        "$and": [{
            "create_at": {
                "$gt": queryDate + " 0:0:0"
            }
        }, {
                "create_at": {
                    "$lt": queryDate + " 23:59:59"
                }
            }]
    };
    OrderProxy.getOrdersByQuery(query, null, function (err, orders) {
        if (err) {
            return next(err);
        }
        //不缓存，解决IE问题
        res.setHeader("Cache-Control", "no-cache");
        res.send({
            data: orders
        });
    });
};
exports.showEdit = function (req, res, next) {
    var order_id = req.params.oid;
    if (order_id) {
        OrderProxy.getOrderById(order_id, function (err, order) {
            if (!order) {
                res.render404('此话题不存在或已被删除。');
                return;
            }
            if (String(order.user_id) === String(req.session.user._id) || req.session.user.is_admin) {
                res.render('order/edit', {
                    action: 'edit',
                    title: '编辑订餐',
                    order_id: order._id,
                    dish_name: order.dish_name,
                    dish_price: order.dish_price,
                    ispack: order.ispack,
{'fraction_non_alphanumeric': 0.14896214896214896, 'fraction_numerical': 0.019536019536019536, 'mean_word_length': 1.5884676145339653, 'pattern_counts': {'":': 10, '<': 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': '2340268', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1110, 'n_words': 191}