var config = require('config');
var db = require('../db.js');

function getTwitterFriends(user_id, twitter_user_id, token_key, token_secret) {
  var twit = require('twit');
  var twitter = new twit({
        consumer_key:         config.twitter.consumer_key, 
        consumer_secret:      config.twitter.consumer_secret, 
        access_token:         token_key, 
        access_token_secret:  token_secret
  });
  
  // save twitter following list to mysql
  twitter.get('friends/ids', { user_id: twitter_user_id },  function (err, data, response) {
    console.log(data);
    for (var i = 0; i < data.ids.length; i++) {
      friend_twitter_id = data.ids[i];
      var post = { user_id: user_id, friend_twitter_id: friend_twitter_id };
      console.log(post);
      var query = db.query('INSERT IGNORE INTO twitter_following SET ?', post, function (err, result) {
        if (err) throw err;
      });
    }
  });
}

function updateFollowing(user_id) {
  var sql = "SELECT user.id AS friend_id FROM user, twitter_following "
          + "WHERE user.twitter_user_id = twitter_following.friend_twitter_id "
          + "AND twitter_following.user_id = ?";

  var query = db.query(sql, user_id, function (err, rows) {
    console.log(query.sql);
    if (err) throw err;
    for (var i in rows) {
      var friend = rows[i];
      var post = { user_id: user_id, friend_id: friend.friend_id, following_status: 1 };
      console.log('friend: ' + friend.friend_id);
      db.query('INSERT IGNORE INTO following SET ?', post, function (err, result) {          
        if (err) throw err;
      });
    }        
  });    
}


exports.getTwitterFriends = getTwitterFriends;
exports.updateFollowing = updateFollowing;
@@ -549,31 +549,8 @@
 ) %7B%0A
-    console.log(data);%0A
     
@@ -713,33 +713,8 @@
  %7D;%0A
-      console.log(post);%0A
     
@@ -1168,36 +1168,8 @@
 ) %7B%0A
-    console.log(query.sql);%0A
     
@@ -1335,58 +1335,8 @@
  %7D;%0A
-      console.log('friend: ' + friend.friend_id);%0A
     

Remove console logging