DashboardHub / TribeDashboard

Dashboard for my social tribe: twitter, youtube, instagram, github
MIT License
4 stars 1 forks source link

Update subscribers and followers count #26

Closed VenkatVenkatesh closed 5 years ago

VenkatVenkatesh commented 5 years ago

3

Include documentation steps for setting up the cron, ideally this is achievable by config in the repo

VenkatVenkatesh commented 5 years ago

This task is to create a cloud function, that would run every 24 hours to fetch all the user's social account's (github and twitter) details like subscribers, followers...etc and store them in a new collection called socialStatsHistory and would contain daywise followers, subscribers, follows counts. Something like

{ "twitter": { "createdOn": "", "subscribers":"" "followers": "", "unfollowers": "", } }

eddiejaoude commented 5 years ago

Note: Store followers, newFollowers, unfollowers as sub collections so they are not brought back with the parent document.


Day 1 with followers 10 Up - / Down -

{
"twitter": {
      "createdOn": "",
      "subscriberCount": 10
      "followerCount": 2,
      "unfollowerCount": 2,
      "followers": ['user a', 'user b', 'user c', 'user d', 'user e', 'user f'],
      "unfollowers": []
   }
}

Day 2 with followers 10

Up 1 / Down 2

{
"twitter": {
      "createdOn": "",
      "subscriberCount": 10
      "followerCount": 2,
      "unfollowerCount": 2,
      "followers": ['user a', 'user b', 'user c', 'user d', 'user g'],
      "newFollowers": ['user g'],
      "unfollowers": ['user e', 'user f']
   }
}

Day 3 with followers 10

Up 2 / Down 1

{
"twitter": {
      "createdOn": "",
      "subscriberCount": 10
      "followerCount": 2,
      "unfollowerCount": 2,
      "followers": ['user b', 'user c', 'user d', 'user g', 'user h', 'user i'],
      "newFollowers": ['user h', 'user i'],
      "unfollowers": ['user a']
   }
}
VenkatVenkatesh commented 5 years ago

@eddiejaoude To update the userSocial stats of twitter, we have the following twitter Api that returns the user stats.

Twitter show API

The above API accepts Bearer token based authorization as show in the example request in the above link.

I am going with bearer token approach @eddiejaoude. Shall we create a separate config collection where we can store the bearer token of the application.

eddiejaoude commented 5 years ago

The collect will only have 1 item in it? Its usually best not to store application specific keys in the code or database, but as environment variables https://firebase.google.com/docs/functions/config-env

VenkatVenkatesh commented 5 years ago

Sounds good. Thank you 👍