TogetherCrew / twitter-analytics

This repository is in responsible of twitter analytics tasks of TogetherCrew.
1 stars 0 forks source link

Compute friendship circle #3

Closed amindadgar closed 1 year ago

amindadgar commented 1 year ago

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

Then with the new 5 properties of each user, we could easily compute

amindadgar commented 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.

amindadgar commented 1 year ago

For friend-type the queries would be (real-time computations)

  1. Acquaintance

    • Number of people whole retweet and likes (We don't have the people who like for now)
      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
  2. 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
  3. 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)

amindadgar commented 1 year ago

Moved to in-review as we need to implement these in backend side with tests!

amindadgar commented 1 year ago

The features for this issue is not gonna be implemented.