0
私は、ユーザがWHERE comment.text =~ { mention }
で言及したコメントだけを返す機能を追加しています。上記のコメントが正しく返信されていますが、commentsCount
はコメント数になります。 WHERE comment.text =~ { mention }
を適用する前に、合計のコメントとしてcommentsCount
を数えられる方法はありますか?正しい合計を得るために(コメント)カウントする方法はありますか?WHERE comment =?
// MENTIONS
MATCH (user:User {user_id: { user_id }})
MATCH (post:Post)<-[:AUTHOR]-(author:User)
WHERE post.createdAt < { before } AND post.text =~ { keyword }
MATCH (post)-[:HAS_COMMENT]->(comment:Comment)<-[:AUTHOR]-(commentAuthor:User)
WHERE NOT user.user_id = commentAuthor.user_id AND comment.text =~ { mention } // filter
WITH
post,
author,
commentAuthor,
max(comment.createdAt) as commentCreatedAt,
count(comment) as commentsPerCommenter
ORDER BY commentCreatedAt DESC
WITH
post,
author,
sum(commentsPerCommenter) as commentsCount,
collect(commentAuthor {.*, commentCreatedAt, commentsCount: commentsPerCommenter}) as commentAuthors
WITH
post,
author,
commentsCount, // incorrect # mentioned comments only, want # total comments
size(commentAuthors) as participantsCount,
commentAuthors
UNWIND commentAuthors as commentAuthor
RETURN collect(post {
.*,
author,
commentAuthor,
commentsCount,
participantsCount,
notificationType: 'mention'
})[0..{ LIMIT }] as posts
これは、これが私に与えられた数字の意味を理解しようとしていることを少し見てから、これは投稿者が投稿した#コメントの数を返すようです。ポストで作られた。 – kayla
私たちが実際にコメントに一致する前に、より早く投稿あたりの総コメント数を計算するために私のクエリを編集しました。 – InverseFalcon
こんにちは、スーパークローズ!これは正しい#合計コメントを返しますが、これはフィルタの後に発生するため、あなたを言及したユーザーの数はparticipantsCountがまだ間違っています。それは素晴らしいです、私は 'size((post) - [:HAS_COMMENT] - >())like commentsCount'のように、WITHで関係を整えることができるかどうか分かりませんでした。私は 'size((post) - [:HAS_COMMENT] - >()< - [:AUTHOR] - ())としてparticipatorsCount'を実行しようとしましたが、 – kayla