<commit_before>var request = require('request');
var mongoose = require('mongoose');
var User = require('../models/User');


/*************************************************************************************
* This post will contain the following things                                        *
* an id param containing the id of the tutor you're liking or disliking              *
* a body containing vote, which can be a 1 if he liked it or -1 if he disliked it    *
* a body containing user, which contains the id of the student that voted            *
*************************************************************************************/
var likes = function(req, res){
  User.findOne({user: req.params.id}, function(err, user){
    if(err){
      console.log(err);
      return err;
    }
    if(user.likes.indexOf(req.body.user) && user.dislikes.indexOf(req.body.user))
      res.send(-1);
    else {
      if(req.params.body.vote == 1){user.likes.push(req.body.user)}
      if(req.params.body.vote == -1){user.dislikes.push(req.body.user)}
      res.send(user);
    }
  });
}
module.exports = likes;<commit_msg>what am i doing with my life, fixed the if that validates if the user already voted<commit_after>var request = require('request');
var mongoose = require('mongoose');
var User = require('../models/User');


/*************************************************************************************
* This post will contain the following things                                        *
* an id param containing the id of the tutor you're liking or disliking              *
* a body containing vote, which can be a 1 if he liked it or -1 if he disliked it    *
* a body containing user, which contains the id of the student that voted            *
*************************************************************************************/
var likes = function(req, res){
  User.findOne({user: req.params.id}, function(err, user){
    if(err){
      console.log(err);
      return err;
    }
    if(user.likes.indexOf(req.body.user)  == 1 && user.dislikes.indexOf(req.body.user) == 1)
      res.send(-1);
    else {
      if(req.params.body.vote == 1){user.likes.push(req.body.user)}
      if(req.params.body.vote == -1){user.dislikes.push(req.body.user)}
      res.send(user);
    }
  });
}
module.exports = likes;
{'fraction_non_alphanumeric': 0.2599914052428019, 'fraction_numerical': 0.005156854318865492, 'mean_word_length': 3.1130742049469964, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '179548', 'n_tokens_mistral': 649, 'n_tokens_neox': 621, 'n_words': 185}