<commit_before>'use strict';

var Poll = require('../models/polls.js');
var id = 1;

function PollHandler () {

	this.getPolls = function (req, res) {
		Poll
			.findOne({ 'poll.id': id }, { '_id': false })
			.exec(function (err, result) {
				if (err) { throw err; }

				res.json(result);
			});
	};

	this.addPoll = function (req, res) {
		Poll.findOne({ 'poll.id': id }, function (err, poll) {
				if (err) {
					return err;
				}
				if (poll) {
					return poll;
				} else {
					var newPoll = new Poll();

					newPoll.poll.id = id;
					newPoll.poll.question = req.question;
					//newPoll.poll.creator  = twitter.username;
					newPoll.poll.choices  = req.choices;
					newPoll.poll.choices.count = 1;

					newPoll.save(function (err) {
						if (err) {
							throw err;
						}
						//id = id++;
						return newPoll;
					});
				}
			});
	};

}

module.exports = PollHandler;
<commit_msg>saving polls<commit_after>'use strict';

var Poll = require('../models/polls.js');
var id = 1;

function PollHandler () {

	this.getPolls = function (req, res) {
		Poll
			.findOne({ 'poll.id': id }, { '_id': false })
			.exec(function (err, result) {
				if (err) { throw err; }

				res.json(result);
			});
	};

	this.addPoll = function (req, res) {
		process.nextTick(function () {
			Poll.findOne({ 'poll.id': id }, function (err, poll) {
				if (err) {
					return err;
				}
				if (poll) {
					return poll;
				} else {
					var newPoll = new Poll();

					newPoll.poll.id = id;
					newPoll.poll.question = req.question;
					//newPoll.poll.creator  = twitter.username;
					newPoll.poll.choices  = req.choices;
					newPoll.poll.choices.count = 1;

					newPoll.save(function (err) {
						if (err) {
							throw err;
						}
						//id = id++;
						return newPoll;
					});
				}
			});
	});
};
}

module.exports = PollHandler;

{'fraction_non_alphanumeric': 0.1699134199134199, 'fraction_numerical': 0.0021645021645021645, 'mean_word_length': 2.1934369602763386, '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': '805500', 'n_tokens_mistral': 899, 'n_tokens_neox': 684, 'n_words': 148}