@ -18,6 +18,9 @@ tagsController.getTag = function(req, res, next) {
return next(err);
}
data.tag = tag;
if (data.topics && !data.topics.length) {
topics.deleteTag(tag);
res.render('tag', data);
});
@ -27,6 +27,11 @@ module.exports = function(Topics) {
db.sortedSetCard('tag:' + tag + ':topics', callback);
};
Topics.deleteTag = function(tag) {
db.delete('tag:' + tag + ':topics');
db.setRemove('tags', tag);
Topics.getTags = function(callback) {
db.getSetMembers('tags', callback);