refactored get_latest_undeleted_pid to not blindly call getPostsByTid in

order to determine post deletion. (issue #320)
v1.18.x
Julian Lam 12 years ago
parent 2b7fd3c9d1
commit 2366e2b209

@ -301,33 +301,16 @@ var RDB = require('./redis.js'),
RDB.lrange('tid:' + tid + ':posts', 0, -1, function(err, pids) {
if (pids.length === 0) return callback(new Error('no-undeleted-pids-found'));
console.log(tid, pids);
pids.reverse();
async.detectSeries(pids, function(pid, next) {
RDB.hget('post:' + pid, 'deleted', function(err, deleted) {
if (deleted === '1') next(true);
if (deleted === '0') next(true);
else next(false);
});
}, function(pid) {
// console.log(pid);
if (pid) callback(null, pid);
else callback(new Error('no-undeleted-pids-found'));
});
});
// posts.getPostsByTid(tid, 0, -1, function(posts) {
// var numPosts = posts.length;
// if (!numPosts)
// return callback(new Error('no-undeleted-pids-found'));
// while (numPosts--) {
// if (posts[numPosts].deleted !== '1') {
// console.log(posts[numPosts].pid);
// callback(null, posts[numPosts].pid);
// return;
// }
// }
// callback(new Error('no-undeleted-pids-found'));
// });
}
}(exports));

@ -514,7 +514,6 @@ var express = require('express'),
});
});
});
}(WebServer));

Loading…
Cancel
Save