<commit_before>var Waitlist = require('./models/waitlist');

module.exports = function(app, passport) {
  // PROFILE SECTION =========================
  // POST to CREATE
  app.post('/api/waitlists', function (req, res) {
    var course;
    console.log("POST: ");
    console.log(req.body);

    //laundry wash clean
    course = new Waitlist({
      provider: req.body.provider.name,
    });
    course.save(function (err) {
      if (!err) {
        return console.log("created");
      } else {
        return console.log(err);
      }
    });
    return res.send(course);
  });

  // Single update
  app.put('/api/waitlists/:id', function (req, res) {
    //{"crn":req.params.crn}
    return Waitlist.findByIdAndUpdate(req.params.id, req.body, function (err, product) {
      //run over the properties

      ///product.description = req.body.description;
        if (!err) {
          console.log("updated");
        } else {
          console.log(err);
        }
        return res.send(product);
      });
  });

  // Single update
  app.put('/api/waitlists/subscribe/:crn', function (req, res) {
    console.log(req.body);
    return Waitlist.find({"crn":req.params.crn}, function (err, data) {
      if (!err) {
        console.log("updated");
        return Waitlist.update({"crn":req.params.crn}, {$set:{"subscribers": JSON.parse(req.body.subscribers)}},  function (err) {
          if (!err) {
            console.log("updated");
          } else {
            console.log(err);
          }
          return res.send("updated");
        });
      } else {
        console.log(err);
        return res.send(err);
      }
      //waitlist.subscribers = req.body.subscribers;
    });
  });

  // GET to READ

  // List waitlists<commit_msg>removed duplicate method can just update directly object<commit_after>var Waitlist = require('./models/waitlist');

module.exports = function(app, passport) {
  // PROFILE SECTION =========================
  // POST to CREATE
  app.post('/api/waitlists', function (req, res) {
    var course;
    console.log("POST: ");
    console.log(req.body);

    //laundry wash clean
    course = new Waitlist({
      provider: req.body.provider.name,
    });
    course.save(function (err) {
      if (!err) {
        return console.log("created");
      } else {
        return console.log(err);
      }
    });
    return res.send(course);
  });

  // Single update
  app.put('/api/waitlists/:id', function (req, res) {
    //{"crn":req.params.crn}
    if (req.body.subscribers !== null){
      req.body.subscribers = JSON.parse(req.body.subscribers);
    }
    return Waitlist.findByIdAndUpdate(req.params.id, req.body, function (err, product) {
      //run over the properties

      ///product.description = req.body.description;
        if (!err) {
          console.log("updated");
        } else {
          console.log(err);
        }
        return res.send(product);
      });
  });


  // GET to READ

  // List waitlists
{'fraction_non_alphanumeric': 0.17658930373360243, 'fraction_numerical': 0.0, 'mean_word_length': 2.236126224156692, 'pattern_counts': {'":': 5, '<': 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': '281201', 'n_tokens_mistral': 936, 'n_tokens_neox': 915, 'n_words': 183}