From 4c524922ccb6178cd055bcd66000bc65b322d87d Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 6 May 2013 19:46:50 +0000 Subject: [PATCH] posts.get().unfactored().refactored().commited().pushed(); if (conflicts) throw new Error ('IGNORED'); yep. --- src/posts.js | 227 +++++++++++++++++++++------------------------------ src/user.js | 21 +++++ 2 files changed, 115 insertions(+), 133 deletions(-) diff --git a/src/posts.js b/src/posts.js index b67afad757..060a4edf97 100644 --- a/src/posts.js +++ b/src/posts.js @@ -5,152 +5,98 @@ var RDB = require('./redis.js'), async = require('async'); (function(Posts) { - //data structure - //*global:next_post_id - // *pid:1:content - // *pid:1:uid - // *pid:1:timestamp - // ***pid:1:replies - // *uid:1:posts - - Posts.get = function(callback, tid, current_user, start, end) { if (start == null) start = 0; if (end == null) end = start + 10; - async.parallel({ - details: function(callback) { - RDB.mget([ - 'tid:' + tid + ':title', - 'tid:' + tid + ':locked' - ], function(results) { - callback(null, { - 'topic_name': results[0], - 'locked': results[1] - }); - }); - }, - posts: function(callback) { - var participant_uids = [], - post_calls = []; - - async.waterfall([ - function(next) { - RDB.lrange('tid:' + tid + ':posts', start, end, function(pids) { - var content = [], - uids = [], - participants = [], - timestamp = [], - pid = [], - post_rep = []; - - for (var i=0, ii=pids.length; i 0) { - RDB.multi() - .mget(content) - .mget(uids) - .mget(timestamp) - .mget(post_rep) - .exec(function(err, replies) { - // Populate uids array - for(var x=0,numReplies=replies[1].length;x