<commit_before>var express = require('express');
var router = express.Router();
var models  = require('../models');

router.get('/', function(req, res, next) {
  models.Ticket.findAll().then(function(users){
    res.json(users);
  });
});

router.post('/', function(req, res) {
  var device_type = req.body.device_type;
  var device_serial_no = req.body.device_serial_no;
  var device_model = req.body.device_model;
  var device_screen_size = req.body.device_screen_size;
  var contact_name = req.body.contact_name;
  var contact_email = req.body.contact_email;

  var ticket = models.Ticket.build({
    device_type: device_type,
    device_serial_no: device_serial_no,
    device_model: device_model,
    device_screen_size: device_screen_size,
    contact_name: contact_name,
    contact_email: contact_email
  });

  ticket.save()
    .then(function() {
      res.status(201).send('Ticket created successfully');
  }).catch(function(error) {
    res.status(400).send('There is a problem when trying to create a ticket : ' + error);
  });
});

router.get('/:id', function(req, res) {
  models.Ticket.findById(req.params.id).then(function(ticket) {
    if(ticket) {
      res.json(ticket);
    } else {
      res.status(404).send('Ticket is not found');
    }
  });
});

router.delete('/:id', function(req, res) {
  models.Ticket.destroy({where: {id: req.params.id}}).then(function(ticketFound) {
    if(ticketFound) {<commit_msg>added update action<commit_after>var express = require('express');
var router = express.Router();
var models  = require('../models');

router.get('/', function(req, res, next) {
  models.Ticket.findAll().then(function(users){
    res.json(users);
  });
});

router.post('/', function(req, res) {
  var device_type = req.body.device_type;
  var device_serial_no = req.body.device_serial_no;
  var device_model = req.body.device_model;
  var device_screen_size = req.body.device_screen_size;
  var contact_name = req.body.contact_name;
  var contact_email = req.body.contact_email;

  var ticket = models.Ticket.build({
    device_type: device_type,
    device_serial_no: device_serial_no,
    device_model: device_model,
    device_screen_size: device_screen_size,
    contact_name: contact_name,
    contact_email: contact_email
  });

  ticket.save()
    .then(function() {
      res.status(201).send('Ticket created successfully');
  }).catch(function(error) {
    res.status(400).send('There is a problem when trying to create a ticket : ' + error);
  });
});

router.put('/:id', function(req, res) {
  var device_type = req.body.device_type;
  var device_serial_no = req.body.device_serial_no;
  var device_model = req.body.device_model;
  var device_screen_size = req.body.device_screen_size;
  var contact_name = req.body.contact_name;
  var contact_email = req.body.contact_email;

  models.Ticket.findById(req.params.id).then(function(ticket) {
    if(ticket) {
      ticket.update({
        device_type: device_type,
        device_serial_no: device_serial_no,
        device_model: device_model,
        device_screen_size: device_screen_size,
        contact_name: contact_name,
        contact_email: contact_email
      }).then(function() {
        res.send('Ticket updated successfully');
      }).catch(function(error) {
        res.status(400).send('There is a problem when trying to update a ticket : ' + error);
      });
    } else {
      res.status(404).send('Ticket is not found');
    }
  });

});

router.get('/:id', function(req, res) {
  models.Ticket.findById(req.params.id).then(function(ticket) {
    if(ticket) {
      res.json(ticket);
    } else {
      res.status(404).send('Ticket is not found');
    }
  });
});

router.delete('/:id', function(req, res) {
  models.Ticket.destroy({where: {id: req.params.id}}).then(function(ticketFound) {
    if(ticketFound) {
{'fraction_non_alphanumeric': 0.14767381076842656, 'fraction_numerical': 0.006272869837950863, 'mean_word_length': 3.8689567430025447, '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': '3592515', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1260, 'n_words': 231}