mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 18:46:01 +01:00
infinite scrolling for topics in category view, changed how topics are stored in categories, using sorted sets instead of sets now, if you update to this commit run node app --upgrade to upgrade the redis schema, #141
This commit is contained in:
46
src/posts.js
46
src/posts.js
@@ -108,6 +108,20 @@ var RDB = require('./redis.js'),
|
||||
});
|
||||
}
|
||||
|
||||
Posts.getPostField = function(pid, field, callback) {
|
||||
RDB.hget('post:' + pid, field, function(err, data) {
|
||||
if(err === null)
|
||||
callback(data);
|
||||
else
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
Posts.setPostField = function(pid, field, value) {
|
||||
RDB.hset('post:' + pid, field, value);
|
||||
}
|
||||
|
||||
|
||||
Posts.getPostsByPids = function(pids, callback) {
|
||||
var posts = [];
|
||||
|
||||
@@ -141,35 +155,6 @@ var RDB = require('./redis.js'),
|
||||
});
|
||||
}
|
||||
|
||||
Posts.getPostField = function(pid, field, callback) {
|
||||
RDB.hget('post:' + pid, field, function(err, data) {
|
||||
if(err === null)
|
||||
callback(data);
|
||||
else
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
Posts.setPostField = function(pid, field, value) {
|
||||
RDB.hset('post:' + pid, field, value);
|
||||
}
|
||||
|
||||
Posts.getPostFields = function(pid, fields, callback) {
|
||||
RDB.hmget('post:' + pid, fields, function(err, data) {
|
||||
if(err === null) {
|
||||
var returnData = {};
|
||||
|
||||
for(var i=0, ii=fields.length; i<ii; ++i) {
|
||||
returnData[fields[i]] = data[i];
|
||||
}
|
||||
|
||||
callback(returnData);
|
||||
}
|
||||
else
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
Posts.get_cid_by_pid = function(pid, callback) {
|
||||
Posts.getPostField(pid, 'tid', function(tid) {
|
||||
if (tid) {
|
||||
@@ -317,7 +302,8 @@ var RDB = require('./redis.js'),
|
||||
|
||||
feed.updateTopic(tid, cid);
|
||||
|
||||
RDB.zadd('categories:recent_posts:cid:' + cid, Date.now(), pid);
|
||||
RDB.zadd('categories:recent_posts:cid:' + cid, timestamp, pid);
|
||||
RDB.zadd('categories:' + cid + ':tid', timestamp, tid);
|
||||
|
||||
// this is a bit of a naive implementation, defn something to look at post-MVP
|
||||
RDB.scard('cid:' + cid + ':active_users', function(amount) {
|
||||
|
||||
Reference in New Issue
Block a user