<commit_before>var Hapi           = require('hapi');
var routes         = require('./routes.js');
var redis          = require("./redis.js");
var server         = new Hapi.Server();

server.connection({
  port: Number(process.env.PORT) || 8000
});

var io = require("socket.io")(server.listener);

io.on("connection", function (socket) {
  // on connection grab all data from redis
  console.log("io connection");

  var allTasks = redis.readAllTasks(function(err, data) {

    if (err) {
       console.log("readAllTasks error:", err);
    } else {
      socket.emit("allTasks", data);
    };
  });

  // when new task is created, store it to redis
  socket.on("task-submitted", function(task) {

    redis.storeTask(task, function() {

      // once task is saved, read all from redis and emit to front end
      var allTasks = redis.readAllTasks(function(err, data) {

        if (err) {
           console.log("readAllTasks error:", err);
        } else {
          socket.emit("update", data);
        };
      });
    });
  });

  socket.on("statusUpdate", function(taskId, taskStatus) {
    redis.updateStatus(taskId, taskStatus, function() {

      // once status is updated, read all from redis and emit to front end
      var allTasks = redis.readAllTasks(function(err, data) {

        if (err) {
           console.log("status update error:", err);
        } else {
          socket.emit("update", data);
        };
      });
    });
  });

});


server.route(routes);

server.start(<commit_msg>semicolons<commit_after>var Hapi           = require('hapi');
var routes         = require('./routes.js');
var redis          = require("./redis.js");
var server         = new Hapi.Server();

server.connection({
  port: Number(process.env.PORT) || 8000
});

var io = require("socket.io")(server.listener);

io.on("connection", function (socket) {
  // on connection grab all data from redis
  console.log("io connection");

  var allTasks = redis.readAllTasks(function(err, data) {

    if (err) {
       console.log("readAllTasks error:", err);
    } else {
      socket.emit("allTasks", data);
    }
  });

  // when new task is created, store it to redis
  socket.on("task-submitted", function(task) {

    redis.storeTask(task, function() {

      // once task is saved, read all from redis and emit to front end
      var allTasks = redis.readAllTasks(function(err, data) {

        if (err) {
           console.log("readAllTasks error:", err);
        } else {
          socket.emit("update", data);
        }
      });
    });
  });

  socket.on("statusUpdate", function(taskId, taskStatus) {
    redis.updateStatus(taskId, taskStatus, function() {

      // once status is updated, read all from redis and emit to front end
      var allTasks = redis.readAllTasks(function(err, data) {

        if (err) {
           console.log("status update error:", err);
        } else {
          socket.emit("update", data);
        }
      });
    });
  });

});


server.route(routes);

server.start(
{'fraction_non_alphanumeric': 0.15059840425531915, 'fraction_numerical': 0.0026595744680851063, 'mean_word_length': 2.4705882352941178, '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': '450322', 'n_tokens_mistral': 933, 'n_tokens_neox': 907, 'n_words': 231}