Closed amindadgar closed 1 year ago
For the friendship circle, we could do the query (real-time query)
OPTIONAL MATCH (t:Tweet {authorId: '{userId}'})<-[r:QUOTED|REPLIED|RETWEETED]-(m:Tweet)
WHERE m.authorId <> '{userId}' AND r.createdAt >= {Epoch7Days}
WITH m.authorId as interaction_authors
OPTIONAL MATCH (t:Tweet {authorId: '{userId}'})-[r:MENTIONED]->(a:TwitterAccount)
WHERE r.createdAt >={Epoch7Days}
WITH COLLECT( DISTINCT interaction_authors) + COLLECT( DISTINCT a.userId) as frinds_circle
UNWIND frinds_circle as friends
RETURN DISTINCT friends
Note: We're not adding the people who likes a tweet as we don't have them for now in our mock data.
Note 2: Please consider changing the {userId} to the userId and {Epoch7Days} with timestamp of 7 days ago.
Note 3: This query will return the userIds, to do the counting we could just change the last line to RETURN COUNT(DISTINCT friends) as friend_count
.
For friend-type the queries would be (real-time computations)
Acquaintance
OPTIONAL MATCH (t:Tweet {authorId: '{userId}'})<-[r:RETWEETED]-(m:Tweet)
WHERE m.authorId <> '{userId}' AND r.createdAt >= {Epoch7Days}
RETURN COUNT(DISTINCT m.authorId) as users_retweet_count
Supporters: number of users either replying, mentioning, or quoting
OPTIONAL MATCH (t:Tweet {authorId: '{userId}'})<-[r:QUOTED|REPLIED]-(m:Tweet)
WHERE m.authorId <> '{userId}' AND r.createdAt >= {Epoch7Days}
WITH DISTINCT m.authorId as interaction_authors
OPTIONAL MATCH (t:Tweet {authorId: '{userId}'})-[r:MENTIONED]->(a:TwitterAccount)
WHERE r.createdAt >={Epoch7Days}
WITH COLLECT(interaction_authors) + COLLECT( DISTINCT a.userId) as frinds_circle
UNWIND frinds_circle as friends
RETURN COUNT(DISTINCT friends) as friend_count
Ambassadors: Number of connectors who do at least two distinct action (reply, mention, quote)
// REPLIED users
OPTIONAL MATCH (t:Tweet {authorId: '{userId}'})<-[r:REPLIED]-(m:Tweet)
WHERE m.authorId <> '{userId}' AND r.createdAt >= {Epoch7Days}
WITH collect(DISTINCT m.authorId) as replied_users
// QUOTED users OPTIONAL MATCH (t:Tweet {authorId: '{userId}'})<-[r:QUOTED]-(m:Tweet) WHERE m.authorId <> '{userId}' AND r.createdAt >= {Epoch7Days} WITH collect(DISTINCT m.authorId) as quoted_users, replied_users
// MENTIONED users OPTIONAL MATCH (t:Tweet {authorId: '{userId}'})-[r:MENTIONED]->(a:TwitterAccount) WHERE r.createdAt >={Epoch7Days} WITH COLLECT(DISTINCT a.userId) as mentioned_users, quoted_users, replied_users
// users that at least was in two interactions WITH apoc.coll.intersection(mentioned_users, quoted_users)
Moved to in-review as we need to implement these in backend side with tests!
The features for this issue is not gonna be implemented.
Based on the web3 foundation, we should compute different engagement for Twitter data in order to find out community types.
The issue is related to computing the friendship metrics on Twitter data. The analytics to compute are
To compute each one the process is explained below
twitterAccount
properties within a time window as below (his refer to the person who tweeted)liked
: People who liked his tweetretweeted
: People who retweeted his tweet.replied
: People who replied his tweet.mentioned
:People who mentioned his tweet.quoted
:People who quoted his tweet.Then with the new 5 properties of each user, we could easily compute