mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 10:06:52 +02:00
footer shows total topic post count
This commit is contained in:
19
src/posts.js
19
src/posts.js
@@ -201,6 +201,8 @@ marked.setOptions({
|
||||
timeout: 2000
|
||||
});
|
||||
|
||||
Posts.getTopicPostStats(socket);
|
||||
|
||||
// Send notifications to users who are following this topic
|
||||
threadTools.notify_followers(tid, uid);
|
||||
|
||||
@@ -265,6 +267,8 @@ marked.setOptions({
|
||||
RDB.zadd(schema.topics().recent, timestamp, tid);
|
||||
RDB.set('tid:' + tid + ':lastposttime', timestamp);
|
||||
|
||||
RDB.incr('totalpostcount');
|
||||
|
||||
user.getUserFields(uid, ['username'], function(data) { // todo parallel
|
||||
//add active users to this category
|
||||
RDB.get('tid:' + tid + ':cid', function(err, cid) {
|
||||
@@ -339,4 +343,19 @@ marked.setOptions({
|
||||
});
|
||||
}
|
||||
|
||||
Posts.getTopicPostStats = function(socket) {
|
||||
RDB.mget(['totaltopiccount', 'totalpostcount'], function(err, data) {
|
||||
if(err === null) {
|
||||
var stats = {
|
||||
topics: data[1]?data[1]:0,
|
||||
posts: data[0]?data[0]:0
|
||||
};
|
||||
|
||||
socket.emit('post.stats', stats);
|
||||
}
|
||||
else
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
}(exports));
|
||||
@@ -368,6 +368,8 @@ marked.setOptions({
|
||||
io.sockets.in('category_' + category_id).emit('event:new_topic', topicData);
|
||||
io.sockets.in('recent_posts').emit('event:new_topic', topicData);
|
||||
});
|
||||
|
||||
posts.getTopicPostStats(socket);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -398,10 +400,12 @@ marked.setOptions({
|
||||
});
|
||||
|
||||
RDB.incr('cid:' + category_id + ':topiccount');
|
||||
RDB.incr('totaltopiccount');
|
||||
|
||||
feed.updateCategory(category_id);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
}(exports));
|
||||
@@ -160,6 +160,10 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
user.count(socket, data);
|
||||
});
|
||||
|
||||
socket.on('post.stats', function(data) {
|
||||
posts.getTopicPostStats(socket);
|
||||
});
|
||||
|
||||
socket.on('user.latest', function(data) {
|
||||
user.latest(socket, data);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user