<commit_before>var Topic = require('./topicSchema');

exports.postTopic = function(req, res) {
    var topic = new Topic(req.body);
    if (!req.user.equals(topic.user)) {
        res.sendStatus(401);
    }
    event.save(function(err, topic) {
        if (err) {
            res.status(500).send(err);
            return;
        }
        res.status(201).json(topic);
    });
};

exports.getTopics = function(req, res) {
    Topic.find(function(err, topics) {
        if (err) {
            res.status(500).send(err);
            return;
        }
        res.json(topics);
    });
};

exports.getTopic = function(req, res) {
    Topic.findById(req.params.topic_id, function(err, topic) {
        if (err) {
            res.status(500).send(err);
            return;
        }
        res.json(topic);
    });
};

exports.putTopic = function(req, res) {
    Topic.findByIdAndUpdate(
        req.params.topic_id,
        req.body,
        {
            //pass the new object to cb function
            new: true,
            //run validations
            runValidators: true
        }, function (err, topic) {
            if (err) {
                res.status(500).send(err);
                return;
            }
            res.json(topic);
        });
};

exports.deleteTopic = function(req, res) {
    Topic.findById(req.params.topic_id, function(err, topic) {
        if (err) {
            res.status(500).send(err);
            return;
        }
        topic.remove();
        res.sendStatus(200);
    })
};<commit_msg>topic schema checked<commit_after>var Topic = require('./topicSchema');

exports.postTopic = function(req, res) {
    var topic = new Topic(req.body);
    topic.save(function(err, topic) {
        if (err) {
            res.status(500).send(err);
            return;
        }
        res.status(201).json(topic);
    });
};

exports.getTopics = function(req, res) {
    Topic.find(function(err, topics) {
        if (err) {
            res.status(500).send(err);
            return;
        }
        res.json(topics);
    });
};

exports.getTopic = function(req, res) {
    Topic.findById(req.params.topic_id, function(err, topic) {
        if (err) {
            res.status(500).send(err);
            return;
        }
        res.json(topic);
    });
};

exports.putTopic = function(req, res) {
    Topic.findByIdAndUpdate(
        req.params.topic_id,
        req.body,
        {
            new: true,
            runValidators: true
        }, function (err, topic) {
            if (err) {
                res.status(500).send(err);
                return;
            }
            res.json(topic);
        });
};

exports.deleteTopic = function(req, res) {
    Topic.findById(req.params.topic_id, function(err, topic) {
        if (err) {
            res.status(500).send(err);
            return;
        }
        topic.remove();
        res.sendStatus(200);
    })
};
{'fraction_non_alphanumeric': 0.14644207631488484, 'fraction_numerical': 0.015469233413544173, 'mean_word_length': 1.6334841628959276, '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': '3495447', 'n_tokens_mistral': 946, 'n_tokens_neox': 903, 'n_words': 150}