var GithubApi = require('github'),
    config = require('../config'),
    Promise = require('promise'),
    _ = require('underscore');

var sockets = [];
var pulls = [];

   function sendInitialData(socket) {
      socket.emit('allPulls', _.invoke(pulls, 'toObject'));
   }

   // TODO: pass along full Pull object to the client, so that CRs, QAs,
   // build status, etc. can be shown.
   function notifyAboutPullStateChange(pull) {
      sockets.forEach(function(socket) {
         socket.emit('pullChange', pull.toObject());
      });
   }

   /**
    * Removes the given socket from the collection
    */
   function removeSocket(socket) {
      var index = sockets.indexOf(socket);
      if (index !== null) {
         sockets.splice(index);
      }
   }

   function getPull(number) {
      return _.find(pulls, function(pull) {
         return pull.data.number === number;
      });
   }

module.exports = {
   addSocket: function(socket) {
      sockets.push(socket);
      sendInitialData(socket);
      socket.on('disconnect', function() {
         removeSocket(socket);
      });
   },

   addPull: function(pull) {
      console.log(pull.data);
      pulls.push(pull);
      notifyAboutPullStateChange(pull);
   },

   updatePull: function(updatedPull) {
      var pull = getPull(updatedPull.data.number);
      if (!pull) {
         this.addPull(updatedPull);
         return;
      }

      _.extend(pull, updatedPull);
      notifyAboutPullStateChange(pull);
   }
};

@@ -1124,38 +1124,8 @@
 ) %7B%0A
-      console.log(pull.data);%0A
     

remove `console.log`