delete tag if it has no topics left

v1.18.x
barisusakli 11 years ago
parent 56f442f283
commit 87fe5bf1bb

@ -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);
};

Loading…
Cancel
Save