<commit_before>module.exports = function(app) {

    // normal routes ===============================================================
    var User = require('../models/user.js');

    app.get('/listPublicPoi', function(req, res) {
        User.aggregate([{ $unwind: { path: '$poi' } }, { $project: { '_id': '$poi._id', 'name': '$poi.name', 'date': '$poi.date', 'latitude': '$poi.latitude', longitude: '$poi.longitude', photo: '$poi.photo', comment: '$poi.comment', public: '$poi.public', creator: '$name' } }, { $match: { public: true } }], function(err, result) {
            if (err) {
                console.log(err)
                res.send({ success: false })
            } else {
                res.send(result)
            }
        })
    });



    app.delete('/poi/:id', function updateUserPOI(req, res) {
        var condition = { 'poi._id': req.params.id };
        var update = { $pull: { poi: { '_id': req.params.id } } };
        var options = { multi: false };
        var callback = function(err, numberAffected) {
            if (err) {
                res.send({ success: false })
            } else res.send({ success: true, number: numberAffected });
        }
        User.update(condition, update, options, callback)
    });

    app.post('/freetextactivity', function (req, res) {
        if (!req.isAuthenticated()) {
         res.send({ success: false, message: "Please authenticate" });
         return;
          }
          var question=req.body.question;
          var response=req.body.response;
          var wrongMessage=req.body.wrongMessage;
          var correctMessage=req.body.correctMessage;
          var imageId=req.body.imageId;
        var condition = { '_id': req.user._id };
        var update = { $push: { freetext: { 'question': question,response:response,correctMessage:correctMessage,wrongMessage:wrongMessage,imageId:imageId } } };
        var options = { multi: false };
        var callback = function(err, numberAffected) {
            if (err) {
                res.send({ success: false })
            } else res.send({ success: true, number: numberAffected });
        }
        User.update(condition, update, options, callback)
    });


app.get('/freetextactivity', function (req, res) {
            if (req.isAuthenticated()) {
            User.findOne({ _id: req.user._id }, function(err, user) {
                res.send(user.freetext);

            })
        } else {
            res.send({ success: false, message: "User not authenticated" })
        }

})
}
<commit_msg>Deletion for activities in document route<commit_after>module.exports = function(app) {

    // normal routes ===============================================================
    var User = require('../models/user.js');

    app.get('/listPublicPoi', function(req, res) {
        User.aggregate([{ $unwind: { path: '$poi' } }, { $project: { '_id': '$poi._id', 'name': '$poi.name', 'date': '$poi.date', 'latitude': '$poi.latitude', longitude: '$poi.longitude', photo: '$poi.photo', comment: '$poi.comment', public: '$poi.public', creator: '$name' } }, { $match: { public: true } }], function(err, result) {
            if (err) {
                console.log(err)
                res.send({ success: false })
            } else {
                res.send(result)
            }
        })
    });



    app.delete('/poi/:id', function updateUserPOI(req, res) {
        var condition = { 'poi._id': req.params.id };
        var update = { $pull: { poi: { '_id': req.params.id } } };
        var options = { multi: false };
        var callback = function(err, numberAffected) {
            if (err) {
                res.send({ success: false })
            } else res.send({ success: true, number: numberAffected });
        }
        User.update(condition, update, options, callback)
    });

    app.post('/freetextactivity', function (req, res) {
        if (!req.isAuthenticated()) {
         res.send({ success: false, message: "Please authenticate" });
         return;
          }
          var question=req.body.question;
          var response=req.body.response;
          var wrongMessage=req.body.wrongMessage;
          var correctMessage=req.body.correctMessage;
          var imageId=req.body.imageId;
        var condition = { '_id': req.user._id };
        var update = { $push: { freetext: { 'question': question,response:response,correctMessage:correctMessage,wrongMessage:wrongMessage,imageId:imageId } } };
        var options = { multi: false };
        var callback = function(err, numberAffected) {
            if (err) {
                res.send({ success: false })
            } else res.send({ success: true, number: numberAffected });
        }
        User.update(condition, update, options, callback)
    });


app.get('/freetextactivity', function (req, res) {
            if (req.isAuthenticated()) {
            User.findOne({ _id: req.user._id }, function(err, user) {
                res.send(user.freetext);

            })
        } else {
            res.send({ success: false, message: "User not authenticated" })
        }

})
}


app.delete('/freetextactivity/:id',function(req,res){
        var condition = { 'freetext._id': req.params.id };
        var update = { $pull: { freetext: { '_id': req.params.id } } };
        var options = { multi: false };
        var callback = function(err, numberAffected) {
            if (err) {
                res.send({ success: false })
            } else res.send({ success: true, number: numberAffected });
        }
        User.update(condition, update, options, callback)
    });
{'fraction_non_alphanumeric': 0.17771030541168065, 'fraction_numerical': 0.0, 'mean_word_length': 2.2202415181138586, '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': '6116549', 'n_tokens_mistral': 1658, 'n_tokens_neox': 1603, 'n_words': 357}