"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")
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)")

View File

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

View File

@ -154,7 +154,7 @@
<ds-space margin="small">
<no-ssr placeholder="Loading...">
<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>
</no-ssr>
</ds-space>
@ -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 []