Permalink
Browse files

making improvements to the feedback server so measurements actually m…

…ean something
  • Loading branch information...
1 parent b9cbc94 commit 84b34ae2811b0868cccf1adb426ab4b328b0839b @zackster committed Jun 16, 2012
Showing with 19 additions and 27 deletions.
  1. +13 −20 app.js
  2. +6 −7 feedback/feedback-server.js
View
@@ -408,21 +408,17 @@ function(err) {
if ((process.env.NODE_ENV || "development") === 'development') {
callback([config.version, isNewUser, user.id, user.publicId, user.lastReceivedMessageIndex, 'Zachary Burt']);
+ user.setForumsId('Zachary Burt');
}
else {
- // console.log("Req is accessible within register.");
var req = client.manager.handshaken[clientId.toString()];
if (req.headers && req.headers.cookie) {
- // console.log("headers and cookies are accessible");
req.cookies = require('connect').utils.parseCookie(req.headers.cookie);
authServer.checkLogin(req,
function(username) {
- // console.log("Check login returned with value: %s", username);
if (username !== false) {
authServer.logged_in_users[user.id] = username;
- // console.log('checkLogin called back with username: ', username);
user.setForumsId(username);
- // console.log(user.forums_id);
callback([config.version, isNewUser, user.id, user.publicId, user.lastReceivedMessageIndex, username]);
}
else {
@@ -440,9 +436,13 @@ function(err) {
authServer.logged_in_users[user.id] = username;
// console.log('checkLogin called back with username: ', username);
user.setForumsId(username);
+ callback([config.version, isNewUser, user.id, user.publicId, user.lastReceivedMessageIndex, username]);
+
+ }
+ else {
+ callback([config.version, isNewUser, user.id, user.publicId, user.lastReceivedMessageIndex, false]);
}
});
- callback([config.version, isNewUser, user.id, user.publicId, user.lastReceivedMessageIndex, false]);
@@ -483,10 +483,7 @@ function(err) {
}
var venterId = room.conversation.venter.userId;
room.sendToUser(venterId, "forum-username", false);
- };
-
-
-
+ };
/**
* Request the current position the client is in the queue for
@@ -523,17 +520,13 @@ function(err) {
socketHandlers.updateHUD = function(client, user, data, callback) {
- // console.log(client);
- // console.log('------------------------------------------------');
- // console.log(user);
- // console.log(data);
- // console.log(callback);
- var listenerId = user.id;
- feedbackServer.getLeaderboardForUser(listenerId,
- function(info) {
- callback(info);
- });
+ // var listenerId = user.id;
+ //
+ // feedbackServer.getLeaderboardForUser(listenerId,
+ // function(info) {
+ // callback(info);
+ // });
return;
};
@@ -33,14 +33,13 @@
self.listenerScores = {};
this.addFeedback = function (feedback) {
- console.log("Adding feedback");
- console.log(feedback);
var instance = new Feedback();
instance.venter = feedback.venter;
- var listener_account = authServer.getUsernameFromListenerId(feedback.listener);
+ var listener_account = authServer.getUsernameFromListenerId(feedback.listener) ? authServer.getUsernameFromListenerId(feedback.listener) : User.getById(feedback.listener).forums_id;
instance.listener = listener_account ? listener_account : feedback.listener;
+
instance.direction = feedback.direction;
var venter_ip = User.getById(feedback.venter).getIPAddress();
var listener_ip = User.getById(feedback.listener).getIPAddress();
@@ -67,7 +66,7 @@
}
else {
console.log('successfully added feedback');
- if(feedback.direction=='negative') {
+ if(feedback.direction==='negative') {
global.bad_ips.push(listener_ip);
}
}
@@ -191,7 +190,7 @@
if(user_position !== -1) { // user is on leaderboard
// console.log("user position", user_position);
var logged_in_user_score = user_scores_sorted[user_position-1].score;
- for(var i=user_position-2; i>=0; i--) {
+ for(var i=user_position-2; i>=0; i-=1) {
// console.log("user scores", user_scores_sorted);
// console.log("i", i);
// console.log("user scores i", user_scores_sorted[i]);
@@ -259,7 +258,7 @@
console.log("error! " + err);
return;
}
- if(docs==0) {
+ if(docs===0) {
callback(true);
}
else {
@@ -281,4 +280,4 @@
-})();
+}());

0 comments on commit 84b34ae

Please sign in to comment.