Category tags (#8938)

* feat: wip category tags

* fix: tag search

* feat: remove debug

* fix: returns of searchTags and autocomplete

* fix: alpha sort

* fix: redis

* fix: delete zsets on category purge, fix another test

* fix: test
This commit is contained in:
Barış Soner Uşaklı
2020-12-06 12:36:40 -05:00
committed by GitHub
parent 792e9e703e
commit d2888d1d1f
7 changed files with 343 additions and 49 deletions

View File

@@ -28,6 +28,7 @@ module.exports = function (Categories) {
async function purgeCategory(cid) {
await db.sortedSetRemove('categories:cid', cid);
await removeFromParent(cid);
await deleteTags(cid);
await db.deleteAll([
'cid:' + cid + ':tids',
'cid:' + cid + ':tids:pinned',
@@ -71,4 +72,10 @@ module.exports = function (Categories) {
'cid:' + cid + ':tag:whitelist',
]);
}
async function deleteTags(cid) {
const tags = await db.getSortedSetMembers('cid:' + cid + ':tags');
await db.deleteAll(tags.map(tag => 'cid:' + cid + ':tag:' + tag + ':topics'));
await db.delete('cid:' + cid + ':tags');
}
};