From 574b42a2a7d8599ee0f370b5a65a3dd3edc67426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Fri, 7 Jun 2019 01:28:55 +0200 Subject: [PATCH] "commentedCount" is different from "commentsCount" One is how many comments you wrote, one is how many **posts** are there with at least one comment of you. E.g. you can comment twice on the same post. You will have a `commentedCount` increase of 1 but a `commentsCount` of 2. FYI @ogerly @Tirokk --- backend/src/schema/types/type/User.gql | 1 + webapp/graphql/UserProfile/User.js | 2 +- webapp/pages/profile/_id/_slug.vue | 17 ++++++++++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index 1287aa45f..6bfb9b986 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -64,6 +64,7 @@ type User { comments: [Comment]! @relation(name: "WROTE", direction: "OUT") commentsCount: Int! @cypher(statement: "MATCH (this)-[:WROTE]->(r:Comment) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(r)") + commentedCount: Int! @cypher(statement: "MATCH (this)-[:WROTE]->(r:Comment)-[:COMMENTS]->(p:Post) WHERE NOT r.deleted = true AND NOT r.disabled = true AND NOT p.deleted = true AND NOT p.disabled = true RETURN COUNT(DISTINCT(p))") shouted: [Post]! @relation(name: "SHOUTED", direction: "OUT") shoutedCount: Int! @cypher(statement: "MATCH (this)-[:SHOUTED]->(r:Post) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(DISTINCT r)") diff --git a/webapp/graphql/UserProfile/User.js b/webapp/graphql/UserProfile/User.js index ad5a4b402..5bfe0510f 100644 --- a/webapp/graphql/UserProfile/User.js +++ b/webapp/graphql/UserProfile/User.js @@ -24,7 +24,7 @@ export default i18n => { } badgesCount shoutedCount - commentsCount + commentedCount followingCount following(first: 7) { id diff --git a/webapp/pages/profile/_id/_slug.vue b/webapp/pages/profile/_id/_slug.vue index 84d507564..90071d322 100644 --- a/webapp/pages/profile/_id/_slug.vue +++ b/webapp/pages/profile/_id/_slug.vue @@ -154,7 +154,7 @@ - + @@ -273,10 +273,18 @@ export default { page: 1, pageSize: 6, tabActive: 'post', - filter + filter, } }, computed: { + hasMore() { + const total = { + post: this.user.contributionsCount, + shout: this.user.shoutedCount, + comment: this.user.commentedCount, + }[this.tabActive] + return this.Post && this.Post.length < total + }, myProfile() { return this.$route.params.id === this.$store.getters['auth/user'].id }, @@ -290,11 +298,6 @@ export default { offset() { return (this.page - 1) * this.pageSize }, - hasMore() { - return ( - this.Post && this.Post.length < this.user.contributionsCount - ) - }, activePosts() { if (!this.Post) { return []