Skip to content

Instantly share code, notes, and snippets.

@kennym
Created January 19, 2016 19:31
Show Gist options
  • Select an option

  • Save kennym/24869fed4d29f8aee5e0 to your computer and use it in GitHub Desktop.

Select an option

Save kennym/24869fed4d29f8aee5e0 to your computer and use it in GitHub Desktop.
User.dataset.each_page(50) do |dataset|
follows = []
followers = []
dataset.each do |user|
puts "Processing user ##{user.id}"
user.favorites.each do |favorite_user|
follows << { source: "flat:#{user.id}", target: "user:#{favorite_user.id}" }
end
user.followers.each do |follower|
followers << { source: "user:#{follower.id}", target: "flat:#{user.id}" }
end
end
STREAM_CLIENT.follow_many(follows)
STREAM_CLIENT.follow_many(followers)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment