forked from ldbc/ldbc_snb_interactive_v1_impls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bi-4.cypher
26 lines (26 loc) · 785 Bytes
/
bi-4.cypher
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Q4. Top message creators in a country
/*
:param date => datetime('2010-10-01') AS date
*/
MATCH (:Country)<-[:IS_PART_OF]-(:City)<-[:IS_LOCATED_IN]-(person:Person)<-[:HAS_MEMBER]-(forum:Forum)
WHERE forum.creationDate > $date
WITH forum, count(person) AS numberOfMembers
ORDER BY numberOfMembers DESC, forum.id ASC
LIMIT 100
WITH collect(forum) AS popularForums
UNWIND popularForums AS forum
MATCH
(forum)-[:HAS_MEMBER]->(person:Person)
OPTIONAL MATCH
(person)<-[:HAS_CREATOR]-(message:Message)-[:REPLY_OF*0..]->(post:Post)<-[:CONTAINER_OF]-(popularForum:Forum)
WHERE popularForum IN popularForums
RETURN
person.id,
person.firstName,
person.lastName,
person.creationDate,
count(DISTINCT message) AS messageCount
ORDER BY
messageCount DESC,
person.id ASC
LIMIT 100