From 130da7509b64aeadca9d90e90b23ccd7edbbc186 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 3 Apr 2025 18:03:53 +0200 Subject: [PATCH] fix(backend): users observing post count (#8295) * do not count users that are deleted or disbled --- backend/src/schema/resolvers/posts.ts | 3 ++- backend/src/schema/types/type/Post.gql | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/schema/resolvers/posts.ts b/backend/src/schema/resolvers/posts.ts index b111678c0..ce342cea7 100644 --- a/backend/src/schema/resolvers/posts.ts +++ b/backend/src/schema/resolvers/posts.ts @@ -485,7 +485,8 @@ export default { shoutedCount: '<-[:SHOUTED]-(related:User) WHERE NOT related.deleted = true AND NOT related.disabled = true', emotionsCount: '<-[related:EMOTED]-(:User)', - observingUsersCount: '<-[related:OBSERVES]-(:User) WHERE related.active = true', + observingUsersCount: + '<-[obs:OBSERVES]-(related:User) WHERE obs.active = true AND NOT related.deleted = true AND NOT related.disabled = true', }, boolean: { shoutedByCurrentUser: diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index ddf6e557e..fcaa5945a 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -192,7 +192,7 @@ type Post { statement: "MATCH (this)<-[obs:OBSERVES]-(u:User {id: $cypherParams.currentUserId}) WHERE obs.active = true RETURN COUNT(u) >= 1" ) observingUsersCount: Int! - @cypher(statement: "MATCH (this)<-[obs:OBSERVES]-(u:User) WHERE obs.active = true RETURN COUNT(DISTINCT u)") + @cypher(statement: "MATCH (this)<-[obs:OBSERVES]-(u:User) WHERE obs.active = true AND NOT u.deleted = true AND NOT u.disabled = true RETURN COUNT(DISTINCT u)") } input _PostInput {