From 3c86b43ba3b98b6d9fe98ac49418a448118e1e92 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Fri, 3 May 2013 13:08:16 -0400 Subject: [PATCH] post count is incrementing when replying --- src/posts.js | 6 ++++-- src/topics.js | 11 ++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/posts.js b/src/posts.js index 5bc0d23410..347fb20c6e 100644 --- a/src/posts.js +++ b/src/posts.js @@ -69,7 +69,7 @@ var RDB = require('./redis.js'), Posts.reply = function(socket, tid, uid, content) { - Posts.create(uid, content, function(pid) { + Posts.create(uid, tid, content, function(pid) { RDB.rpush('tid:' + tid + ':posts', pid); socket.emit('event:alert', { @@ -81,7 +81,7 @@ var RDB = require('./redis.js'), }); }; - Posts.create = function(uid, content, callback) { + Posts.create = function(uid, tid, content, callback) { if (uid === null) return; RDB.incr('global:next_post_id', function(pid) { @@ -90,6 +90,8 @@ var RDB = require('./redis.js'), RDB.set('pid:' + pid + ':uid', uid); RDB.set('pid:' + pid + ':timestamp', new Date().getTime()); + RDB.incr('tid:' + tid + ':postcount'); + // User Details - move this out later RDB.lpush('uid:' + uid + ':posts', pid); diff --git a/src/topics.js b/src/topics.js index 01f1849a3b..e7bf01bb33 100644 --- a/src/topics.js +++ b/src/topics.js @@ -75,7 +75,9 @@ var RDB = require('./redis.js'), timestamp = replies[2]; slug = replies[3]; postcount = replies[4]; - + + + user.get_usernames_by_uids(uid, function(userNames) { var topics = []; @@ -116,8 +118,9 @@ var RDB = require('./redis.js'), }); return; // for now, until anon code is written. } - + RDB.incr('global:next_topic_id', function(tid) { + // Global Topics if (uid == null) uid = 0; if (uid !== null) { @@ -141,7 +144,9 @@ var RDB = require('./redis.js'), RDB.set('tid:' + tid + ':slug', slug); RDB.set('tid:' + tid + ':timestamp', new Date().getTime()); RDB.incr('tid:' + tid + ':postcount'); - + + + RDB.set('topic:slug:' + slug + ':tid', tid); // Posts