feat: move postercount to topic hash

This commit is contained in:
Barış Soner Uşaklı
2020-10-24 21:14:52 -04:00
parent 203db47b30
commit 0db0231cff
7 changed files with 40 additions and 5 deletions

View File

@@ -174,6 +174,8 @@ module.exports = function (Topics) {
}
await Topics.increasePostCount(tid);
await db.sortedSetIncrBy('tid:' + tid + ':posters', 1, postData.uid);
const posterCount = await db.sortedSetCard('tid:' + tid + ':posters');
await Topics.setTopicField(tid, 'postercount', posterCount);
await Topics.updateTeaser(tid);
};
@@ -184,6 +186,9 @@ module.exports = function (Topics) {
], postData.pid);
await Topics.decreasePostCount(tid);
await db.sortedSetIncrBy('tid:' + tid + ':posters', -1, postData.uid);
await db.sortedSetsRemoveRangeByScore(['tid:' + tid + ':posters'], '-inf', 0);
const posterCount = await db.sortedSetCard('tid:' + tid + ':posters');
await Topics.setTopicField(tid, 'postercount', posterCount);
await Topics.updateTeaser(tid);
};