Squashed commit of the following:

commit 4e0e792232
Merge: 24d0999fb5 70b4a0e2ae
Author: Barış Soner Uşaklı <barisusakli@gmail.com>
Date:   Fri Jun 7 19:26:49 2024 -0400

    Merge branch 'master' into develop

commit 70b4a0e2ae
Author: Barış Soner Uşaklı <barisusakli@gmail.com>
Date:   Fri Jun 7 19:14:13 2024 -0400

    feat: allow passing min,max to sortedSetsCardSum

    to get rid of multiple db calls in profile page

commit 6bbe3d1c4c
Author: Barış Soner Uşaklı <barisusakli@gmail.com>
Date:   Fri Jun 7 14:08:48 2024 -0400

    fix: dont show error alert when user user mouse overs votes

    if they dont have permission to view votes

commit 24d0999fb5
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Thu Jun 6 13:49:14 2024 -0400

    fix(deps): update dependency pg-cursor to v2.11.0 (#12617)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit bee05fe212
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Thu Jun 6 13:28:59 2024 -0400

    fix(deps): update dependency pg to v8.12.0 (#12616)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
Barış Soner Uşaklı
2024-06-07 19:27:44 -04:00
parent 6ecc791db9
commit b1f9ad5534
8 changed files with 116 additions and 81 deletions

View File

@@ -190,8 +190,8 @@ async function getCounts(userData, callerUID) {
const cids = await categories.getCidsByPrivilege('categories:cid', callerUID, 'topics:read');
const promises = {
posts: db.sortedSetsCardSum(cids.map(c => `cid:${c}:uid:${uid}:pids`)),
best: Promise.all(cids.map(async c => db.sortedSetCount(`cid:${c}:uid:${uid}:pids:votes`, 1, '+inf'))),
controversial: Promise.all(cids.map(async c => db.sortedSetCount(`cid:${c}:uid:${uid}:pids:votes`, '-inf', -1))),
best: db.sortedSetsCardSum(cids.map(c => `cid:${c}:uid:${uid}:pids:votes`), 1, '+inf'),
controversial: db.sortedSetsCardSum(cids.map(c => `cid:${c}:uid:${uid}:pids:votes`), '-inf', -1),
topics: db.sortedSetsCardSum(cids.map(c => `cid:${c}:uid:${uid}:tids`)),
};
if (userData.isAdmin || userData.isSelf) {
@@ -207,8 +207,6 @@ async function getCounts(userData, callerUID) {
}
const counts = await utils.promiseParallel(promises);
counts.posts = isRemote ? userData.postcount : counts.posts;
counts.best = counts.best.reduce((sum, count) => sum + count, 0);
counts.controversial = counts.controversial.reduce((sum, count) => sum + count, 0);
counts.categoriesWatched = counts.categoriesWatched && counts.categoriesWatched.length;
counts.groups = userData.groups.length;
counts.following = userData.followingCount;