<commit_before>var url = require('url');
var rewriteAttributeForUser = require('../../util/rewriteUser.js');

/**
 * Add a movie to a user's watchlist
 * @param  {Request}  req  Request
 * @param  {Response} res  Response
 * @return {void}          nothing
 */
var watchlistPost = function(req, res) {
  var queryObject = url.parse(req.url, true);
  var query = queryObject.query;
  try {
    var movie = query.movie;
    rewriteAttributeForUser(req, function(user){
      var list = user.watchlist;
      if (list.indexOf(movie) < 0) {
        return user;
      } else {
        list.push(movie);
        user.watchlist = list;
        return user;
      }
    },res);
  } catch (e) {
    res.writeHead(501, {'Content-Type': 'application/json'});
    res.end("You need to specify what setting to add through the query.");
  }
};

module.exports = watchlistPost;<commit_msg>fixing mistake in the watchlist backend<commit_after>var url = require('url');
var rewriteAttributeForUser = require('../../util/rewriteUser.js');

/**
 * Add a movie to a user's watchlist
 * @param  {Request}  req  Request
 * @param  {Response} res  Response
 * @return {void}          nothing
 */
var watchlistPost = function(req, res) {
  var queryObject = url.parse(req.url, true);
  var query = queryObject.query;
  try {
    var movie = query.movie;
    rewriteAttributeForUser(req, function(user){
      var list = user.watchlist;
      if (list.indexOf(movie) >= 0) {
        return user;
      } else {
        list.push(movie);
        user.watchlist = list;
        return user;
      }
    },res);
  } catch (e) {
    res.writeHead(501, {'Content-Type': 'application/json'});
    res.end("You need to specify what setting to add through the query.");
  }
};

module.exports = watchlistPost;
{'fraction_non_alphanumeric': 0.1389983117613956, 'fraction_numerical': 0.004501969611705121, 'mean_word_length': 2.815450643776824, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '5248995', 'n_tokens_mistral': 568, 'n_tokens_neox': 550, 'n_words': 152}