Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stream - Get the total number of followers

Tags:

getstream-io

I've created a feed reference and fetched the followers like so:

var admin = client.feed('user', 'admin');
const res = await admin.followers();

But the returned result contains paginated data. How can I count the total number of followers?

Will this feature be available or any rough estimation on the roadmap?

Is there any other recommended architecture to get this total count when working with Stream?

like image 880
Yaron Levi Avatar asked Jan 17 '18 19:01

Yaron Levi


2 Answers

Looks like this is not supported yet.

Dwight Gunning wrote on github on 3rd of May, 2018:

Thanks for the interest. This is still on our long-range backlog.

https://github.com/GetStream/stream-django/issues/42

like image 139
Vladimir Marton Avatar answered Oct 28 '22 03:10

Vladimir Marton


It's now supported with the client.followStats() function:

// get follower and following stats of the feed 
client.feed('user', 'me').followStats() 
 
// get follower and following stats of the feed but also filter with given slugs 
// count by how many timelines follow me 
// count by how many markets are followed 
client.feed.followStats({followerSlugs: ['timeline'], followingSlugs: ['market']})

Which returns something like:

{  
  results: { 
    followers: { count: 1529, feed: 'user:me' }, 
    followings: { count: 81, feed: 'user:me' }   
  }, 
  duration: '1.92ms' 
}

Here is the API documentation for it: https://getstream.io/activity-feeds/docs/node/following/?language=javascript#reading-follow-stats

like image 41
tobias Avatar answered Oct 28 '22 01:10

tobias