<commit_before>var redis = require("redis"),
    url = require("url"),
    client;

function setUp(app, options) {
  app.get('/priorities', retrieve);
  app.put('/priorities', update);
  app.post('/priorities', update);

  var redisUrl = url.parse(options.url);
  client = redis.createClient(redisUrl.port, redisUrl.hostname);
  if(redisUrl.auth) {
    client.auth(redisUrl.auth.split(":")[1]);
  }
}

function retrieve(req, res) {
  var query = req.query;
  console.log(query.track)
  client.get("priority:" + query.track, function(err, reply) {
    if(err) {
      console.log(err);
    }
    console.log(reply)
    res
      .send({issues: JSON.parse(reply)})
      .status(200);
  });
}

function update(req, res) {
  var body = req.body;
  console.log(req.body);
  var priorities = body.issues || [];
  client.set("priority:" + body.track, JSON.stringify(priorities));
  res
    .send({})
    .status(201);
}


module.exports = setUp;<commit_msg> fixing behaviour when there is no redistogo configuration<commit_after>var redis = require("redis"),
url = require("url"),
client;

function setUp(app, options) {
  app.get('/priorities', retrieve);
  app.put('/priorities', update);
  app.post('/priorities', update);

  
    var redisUrl = url.parse(options.url);
    client = redis.createClient(redisUrl.port, redisUrl.hostname);

    client.on('error', function(event) {
      
      console.log('fail in connect with redis');
      client = undefined;

    });

    if(redisUrl.auth) {
      client.auth(redisUrl.auth.split(":")[1]);
    }
  
}

function retrieve(req, res) {
  var query = req.query;
  console.log(query.track)
  if(client){
    client.get("priority:" + query.track, function(err, reply) {
      if(err) {
        console.log(err);
      }
      console.log(reply)
      res
      .send({issues: JSON.parse(reply)})
      .status(200);
    });
  }
  else{
    res.send({}).status(503);
  } 

}

function update(req, res) {
  var body = req.body;
  console.log(req.body);
  var priorities = body.issues || [];
  if(client){
    client.set("priority:" + body.track, JSON.stringify(priorities));
    res
    .send({})
    .status(201);
  } else {
    res.send({})
    .status(503);
  }
}


module.exports = setUp;
{'fraction_non_alphanumeric': 0.1768920734437976, 'fraction_numerical': 0.008956560680698611, 'mean_word_length': 3.129390018484288, 'pattern_counts': {'":': 2, '<': 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': '5353062', 'n_tokens_mistral': 803, 'n_tokens_neox': 772, 'n_words': 141}