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

/* GET users listing. */
router.get('/', function(req, res, next) {
  connection.query('SELECT * FROM comics', function (error, results, fields) {
    if(error){
      res.send(JSON.stringify({"status": 500, "error": error, "response": null})); 
      //If there is error, we send the error in the error section with 500 status
    } else {
      res.send(JSON.stringify({"status": 200, "error": null, "response": results}));
      //If there is no error, all is good and response is 200OK.
    }
  });
});

router.get('/:slug', function(req, res, next) {
  connection.query('SELECT * FROM comics WHERE slug = "' + req.params.slug + '" LIMIT 1', function (error, results, fields) {
    if(error){
      res.send(JSON.stringify({"status": 500, "error": error, "response": null})); 
      //If there is error, we send the error in the error section with 500 status
    } else {
      res.send(JSON.stringify({"status": 200, "error": null, "response": results}));
      //If there is no error, all is good and response is 200OK.
    }
  });
});

router.get('/:slug/navigation', function(req, res, next) {
  console.log(req.params.slug);

  var currentQuery = 'SELECT date FROM comics WHERE slug ="'+req.params.slug+'"';
  var previousQuery = 'SELECT slug FROM comics WHERE date < ('+currentQuery+') order by date desc limit 1';
  var nextQuery = 'SELECT slug FROM comics WHERE date > ('+currentQuery+') order by date desc limit 1';
  var randomQuery = 'SELECT slug FROM comics ORDER BY RAND() WHERE slug <> "'+req.params.slug+'" LIMIT 1';

  connection.query([previousQuery, nextQuery, randomQuery].join('; '), ['previousSlug', 'nextSlug', 'randomSlug'], function(err, results) {
    if (err) throw err;

    console.log(results); // [{1: 1}]
  });

  // var currentQuery = 'SELECT date FROM comics WHERE slug ="' + req.params.slug + '"'
  // connection.query('select slug from comics where 'date' < (select 'date' from comics where id=4) order by 'date' desc limit 1', function (error, results, fields) {
  //   if(error){
  //     res.send(JSON.stringify({"status": 500, "error": error, "response": null})); 
  //     //If there is error, we send the error in the error section with 500 status
  //   } else {
  //     connection.query('select slug from comics where 'date' > (select 'date' from comics where id=4) order by 'date' desc limit 1', function (error2, results2, fields2) {
  //       if(error){
  //         res.send(JSON.stringify({"status": 500, "error": error, "response": null})); 
  //         //If there is error, we send the error in the error section with 500 status
  //       } else {
  //         console.log(results, results2);
  //         // res.send(JSON.stringify({"status": 200, "error": null, "response": [nextSlug: results]}));
  //       }
  //     });
  //     // res.send(JSON.stringify({"status": 200, "error": null, "response": results}));
  //     //If there is no error, all is good and response is 200OK.
  //   }
  // });
});

module.exports = router;<commit_msg>fixed<commit_after>var express = require('express');
var router = express.Router();

/* GET users listing. */
router.get('/', function(req, res, next) {
  connection.query('SELECT * FROM comics', function (error, results, fields) {
    if(error){
      res.send(JSON.stringify({"status": 500, "error": error, "response": null})); 
      //If there is error, we send the error in the error section with 500 status
    } else {
      res.send(JSON.stringify({"status": 200, "error": null, "response": results}));
      //If there is no error, all is good and response is 200OK.
    }
  });
});

router.get('/:slug', function(req, res, next) {
  connection.query('SELECT * FROM comics WHERE slug = "' + req.params.slug + '" LIMIT 1', function (error, results, fields) {
    if(error){
      res.send(JSON.stringify({"status": 500, "error": error, "response": null})); 
      //If there is error, we send the error in the error section with 500 status
    } else {
      res.send(JSON.stringify({"status": 200, "error": null, "response": results}));
      //If there is no error, all is good and response is 200OK.
    }
  });
});

router.get('/:slug/navigation', function(req, res, next) {
  console.log(req.params.slug);

  var currentQuery = 'SELECT date FROM comics WHERE slug ="'+req.params.slug+'"';
  var previousQuery = 'SELECT slug FROM comics WHERE date < ('+currentQuery+') order by date desc limit 1';
  var nextQuery = 'SELECT slug FROM comics WHERE date > ('+currentQuery+') order by date desc limit 1';
  var randomQuery = 'SELECT slug FROM comics ORDER BY RAND() WHERE slug <> "'+req.params.slug+'" LIMIT 1';

  console.log([previousQuery, nextQuery, randomQuery].join('; '));

  connection.query([previousQuery, nextQuery, randomQuery].join('; '), ['previousSlug', 'nextSlug', 'randomSlug'], function(err, results) {
    if (err) throw err;

    console.log(results); // [{1: 1}]
  });

  // var currentQuery = 'SELECT date FROM comics WHERE slug ="' + req.params.slug + '"'
  // connection.query('select slug from comics where 'date' < (select 'date' from comics where id=4) order by 'date' desc limit 1', function (error, results, fields) {
  //   if(error){
  //     res.send(JSON.stringify({"status": 500, "error": error, "response": null})); 
  //     //If there is error, we send the error in the error section with 500 status
  //   } else {
  //     connection.query('select slug from comics where 'date' > (select 'date' from comics where id=4) order by 'date' desc limit 1', function (error2, results2, fields2) {
  //       if(error){
  //         res.send(JSON.stringify({"status": 500, "error": error, "response": null})); 
  //         //If there is error, we send the error in the error section with 500 status
  //       } else {
  //         console.log(results, results2);
  //         // res.send(JSON.stringify({"status": 200, "error": null, "response": [nextSlug: results]}));
  //       }
  //     });
  //     // res.send(JSON.stringify({"status": 200, "error": null, "response": results}));
  //     //If there is no error, all is good and response is 200OK.
  //   }
  // });
});

module.exports = router;
{'fraction_non_alphanumeric': 0.16993254095727595, 'fraction_numerical': 0.018952778670093158, 'mean_word_length': 3.2074324324324324, 'pattern_counts': {'":': 48, '<': 9, '<?xml version=': 0, '>': 9, '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': '322219', 'n_tokens_mistral': 2022, 'n_tokens_neox': 1873, 'n_words': 640}