Open amindadgar opened 1 year ago
The analytics seem to be able to be done using pure cypher queries in back-end. Here's the queries for each and we could do more filtering them in backend codes.
We will count each person's interactions with people and return the counts
Reply count of each user
MATCH (t:Tweet {authorId: '{userId}'})<-[r:REPLIED]-(m:Tweet)
WHERE m.authorId <> t.authorId AND r.createdAt >= {Epoch7daysAgo}
RETURN m.authorId AS user, COUNT(*) as reply_count
Quote count of each user
MATCH (t:Tweet {authorId: '{userId}'})<-[r:QUOTED]-(m:Tweet)
WHERE m.authorId <> t.authorId AND r.createdAt >= {Epoch7daysAgo}
RETURN m.authorId AS user, COUNT(*) as quote_count
Mention count of each user
MATCH (a:TwitterAccount {userId: '{userId}'})<-[r:MENTIONED]-(t:Tweet)
WHERE a.userId <> t.authorId AND r.createdAt >= {Epoch7daysAgo}
RETURN t.authorId AS user, COUNT (*) as mention_count
Retweet count of each user
MATCH (t:Tweet {authorId: '{userId}'})<-[r:RETWEETED]-(m:Tweet)
WHERE t.authorId <> m.authorId AND r.createdAt >= {Epoch7daysAgo}
RETURN m.authorId AS user, COUNT (*) as retweet_count
Likes count of each user
MATCH (t:Tweet {authorId: '{userId}'}) <-[:LIKED]- (a:TwitterAccount)
WHERE a.userId <> t.authorId
RETURN a.userId, COUNT(*) as likes_count
Note 2: The {userId}
is related to the main userId which they connected to our system.
Note 3: The {Epoch7daysAgo}
is representative of 7 days ago timestamp.
We want to compute the analytics of "engagement by account" section. Basically, what it is, is explained as below