From d55f8742b8cd6b2965c5e93690c8a57d9350b8e1 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 27 May 2023 20:34:28 +0200 Subject: [PATCH] cache when computing note count etc. --- packages/backend/src/server/api/endpoints/users/stats.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/backend/src/server/api/endpoints/users/stats.ts b/packages/backend/src/server/api/endpoints/users/stats.ts index 3780b9eb0..1a0e9031e 100644 --- a/packages/backend/src/server/api/endpoints/users/stats.ts +++ b/packages/backend/src/server/api/endpoints/users/stats.ts @@ -182,6 +182,13 @@ export default define(meta, paramDef, async (ps, me) => { result.followingCount = result.localFollowingCount + result.remoteFollowingCount; result.followersCount = result.localFollowersCount + result.remoteFollowersCount; + + // store the updated counts in the user table to potentially fix the cache + Users.update(user.id, { + followersCount: result.followersCount, + followingCount: result.followingCount, + notesCount: result.notesCount, + }); } return result;