<commit_before>Meteor.methods({
	'discussionComments.insert': function insertDiscussionComment(discussionCommentCandidate) {
		check(discussionCommentCandidate, Object);
		const discussionComment = discussionCommentCandidate;
		// Make sure the user is logged in before inserting
		if (!this.userId) {
			throw new Meteor.Error('not-authorized');
		}

		const currentUser = Meteor.users.findOne({ _id: this.userId });
		discussionComment.user = currentUser;
		discussionComment.votes = 1;
		discussionComment.voters = [currentUser._id];

		// check(discussionComment.user, Schemas.User);
		check(discussionComment.content, String);
		check(discussionComment.votes, Number);
		check(discussionComment.commentId, String);

		console.log('Inserting new comment', discussionComment);
		try {
			DiscussionComments.insert(discussionComment);
		} catch (err) {
			console.log(err);
		}
	},

	'discussionComments.update': function updateDiscussionComment(discussionCommentData) {
		check(discussionCommentData, Object);
		console.log('Discussion comment update:', discussionCommentData);

		const discussionComment = DiscussionComments.findOne({
			_id: discussionCommentData._id,
		});

		// Make sure the user has auth to edit
		if (this.userId !== discussionComment.user._id) {
			throw new Meteor.Error('not-authorized');
		}

		check(discussionCommentData.content, String);
		console.log('Updating comment', discussionComment);
		try {
			DiscussionComments.update({
				_id: discussionComment._id,
			}, {
				$set: {
					content: discussionCommentData.content,
				},
			});
		} catch (err) {
			console.log(err);
		}
	},

	'discussionComments.upvote': function upvoteDiscussionComment(discussionCommentId) {
		check(discussionCommentId, Number);

		const discussionComment = DiscussionComments.findOne(discussionCommentId);

		// Make sure the user has not already upvoted
		if (discussionComment.voters.indexOf(this.userId) >= 0) {
			throw new Meteor.Error('not-authorized');
		}

		try {
			DiscussionComments.update({
				_id: discussionCommentId,
			}, {
				$push: { voters: this.userId },
				$inc: { votes: 1 },
			});
		} catch (err) {
			console.log(err);
		}
	},

});
<commit_msg>discussionComments.upvote fix<commit_after>Meteor.methods({
	'discussionComments.insert': function insertDiscussionComment(discussionCommentCandidate) {
		check(discussionCommentCandidate, Object);
		const discussionComment = discussionCommentCandidate;
		// Make sure the user is logged in before inserting
		if (!this.userId) {
			throw new Meteor.Error('not-authorized');
		}

		const currentUser = Meteor.users.findOne({ _id: this.userId });
		discussionComment.user = currentUser;
		discussionComment.votes = 1;
		discussionComment.voters = [currentUser._id];

		// check(discussionComment.user, Schemas.User);
		check(discussionComment.content, String);
		check(discussionComment.votes, Number);
		check(discussionComment.commentId, String);

		console.log('Inserting new comment', discussionComment);
		try {
			DiscussionComments.insert(discussionComment);
		} catch (err) {
			console.log(err);
		}
	},

	'discussionComments.update': function updateDiscussionComment(discussionCommentData) {
		check(discussionCommentData, Object);
		console.log('Discussion comment update:', discussionCommentData);

		const discussionComment = DiscussionComments.findOne({
			_id: discussionCommentData._id,
		});

		// Make sure the user has auth to edit
		if (this.userId !== discussionComment.user._id) {
			throw new Meteor.Error('not-authorized');
		}

		check(discussionCommentData.content, String);
		console.log('Updating comment', discussionComment);
		try {
			DiscussionComments.update({
				_id: discussionComment._id,
			}, {
				$set: {
					content: discussionCommentData.content,
				},
			});
		} catch (err) {
			console.log(err);
		}
	},

	'discussionComments.upvote': function upvoteDiscussionComment(discussionCommentId) {
		check(discussionCommentId, String);

		const discussionComment = DiscussionComments.findOne(discussionCommentId);

		// Make sure the user has not already upvoted
		if (discussionComment.voters.indexOf(this.userId) >= 0) {
			throw new Meteor.Error('not-authorized');
		}

		try {
			DiscussionComments.update({
				_id: discussionCommentId,
			}, {
				$push: { voters: this.userId },
				$inc: { votes: 1 },
			});
		} catch (err) {
			console.log(err);
		}
	},

});

{'fraction_non_alphanumeric': 0.12244434348023625, 'fraction_numerical': 0.0013630168105406633, 'mean_word_length': 4.524466750313676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1440321', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1265, 'n_words': 259}