TogetherCrew / twitter-analytics

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

Metrics: "Engagement by account" section #5

Open amindadgar opened 1 year ago

amindadgar commented 1 year ago

We want to compute the analytics of "engagement by account" section. Basically, what it is, is explained as below

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

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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.