"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
This commit is contained in:
Robert Schäfer 2019-06-07 01:28:55 +02:00
parent d3a70321b8
commit 574b42a2a7
3 changed files with 12 additions and 8 deletions

View File

@ -64,6 +64,7 @@ type User {
comments: [Comment]! @relation(name: "WROTE", direction: "OUT") 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)") 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") 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)") shoutedCount: Int! @cypher(statement: "MATCH (this)-[:SHOUTED]->(r:Post) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(DISTINCT r)")

View File

@ -24,7 +24,7 @@ export default i18n => {
} }
badgesCount badgesCount
shoutedCount shoutedCount
commentsCount commentedCount
followingCount followingCount
following(first: 7) { following(first: 7) {
id id

View File

@ -154,7 +154,7 @@
<ds-space margin="small"> <ds-space margin="small">
<no-ssr placeholder="Loading..."> <no-ssr placeholder="Loading...">
<ds-number :label="$t('profile.commented')"> <ds-number :label="$t('profile.commented')">
<hc-count-to slot="count" :end-val="user.commentsCount" /> <hc-count-to slot="count" :end-val="user.commentedCount" />
</ds-number> </ds-number>
</no-ssr> </no-ssr>
</ds-space> </ds-space>
@ -273,10 +273,18 @@ export default {
page: 1, page: 1,
pageSize: 6, pageSize: 6,
tabActive: 'post', tabActive: 'post',
filter filter,
} }
}, },
computed: { 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() { myProfile() {
return this.$route.params.id === this.$store.getters['auth/user'].id return this.$route.params.id === this.$store.getters['auth/user'].id
}, },
@ -290,11 +298,6 @@ export default {
offset() { offset() {
return (this.page - 1) * this.pageSize return (this.page - 1) * this.pageSize
}, },
hasMore() {
return (
this.Post && this.Post.length < this.user.contributionsCount
)
},
activePosts() { activePosts() {
if (!this.Post) { if (!this.Post) {
return [] return []