From 08c303b3c720cbe5c9e8943799c2bd581247d342 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 6 May 2013 10:05:00 -0400 Subject: [PATCH] interim commit --- package.json | 3 ++- src/posts.js | 52 +++++++++++++++++++++++++++++++++++++++++++++++- src/webserver.js | 6 ++++++ 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ade3d36f7c..69583881ff 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "less-middleware": "0.1.11", "marked": "0.2.8", "bcrypt": "0.7.5", - "node-gyp": "0.9.5" + "node-gyp": "0.9.5", + "async": "0.2.8" }, "devDependencies": {}, "optionalDependencies": {}, diff --git a/src/posts.js b/src/posts.js index bd16f056af..d15d9c15d5 100644 --- a/src/posts.js +++ b/src/posts.js @@ -1,7 +1,8 @@ var RDB = require('./redis.js'), utils = require('./utils.js'), marked = require('marked'), - user = require('./user.js'); + user = require('./user.js'), + async = require('async'); (function(Posts) { //data structure @@ -18,6 +19,55 @@ var RDB = require('./redis.js'), if (start == null) start = 0; if (end == null) end = start + 10; + // async.parallel({ + // details: function(callback) { + // RDB.get('tid:' + tid + ':title', function(topic_name) { + // callback(null, { + // 'topic_name': topic_name + // }); + // }); + // }, + // posts: function(callback) { + // var participant_uids = [], + // post_calls = []; + // RDB.lrange('tid:' + tid + ':posts', start, end, function(pids) { + // var content = [], + // uid = [], + // timestamp = [], + // pid = [], + // post_rep = []; + + // for (var i=0, ii=pids.length; i 0) { + // RDB.multi() + // .mget(content) + // .mget(uid) + // .mget(timestamp) + // .mget(post_rep) + // .exec(function(err, replies) { + // content = replies[0]; + // uid = replies[1]; + // timestamp = replies[2]; + // post_rep = replies[3]; + + // callback(null, replies); + // } + // ); + // } + // }); + // } + // }, function(err, results) { + // callback(results); + // }); + // return; + RDB.get('tid:' + tid + ':title', function(topic_name) { //do these asynch later RDB.lrange('tid:' + tid + ':posts', start, end, function(pids) { var content = [], diff --git a/src/webserver.js b/src/webserver.js index e1cf20d051..30362cba30 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -298,6 +298,12 @@ passport.deserializeUser(function(uid, done) { res.send('User profile for uid: ' + uid); }); }); + + app.get('/test', function(req, res) { + global.modules.posts.get(function(data) { + res.send('
' + JSON.stringify(data) + '
'); + }, 1, 1); + }); }(WebServer)); server.listen(config.port);