Skip to content

Instantly share code, notes, and snippets.

@plotti
Created June 8, 2012 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plotti/2895615 to your computer and use it in GitHub Desktop.
Save plotti/2895615 to your computer and use it in GitHub Desktop.
Collect list members
def self.collect_list_members(username, list_id,project_id)
while Project.get_remaining_hits == "timeout"
puts "collect_list_members waiting..."
sleep(60)
end
result = @@twitter.list_members(username, list_id, {:cursor => -1})
members = result["users"]
next_cursor = result["next_cursor"]
old_next_cursor = 0
while old_next_cursor != next_cursor and next_cursor != 0
old_next_cursor = next_cursor
result = @@twitter.list_members(username, list_id, {:cursor => next_cursor })
members = members + result["users"]
next_cursor = result["next_cursor"]
puts "Member Count #{members.count} next cursor: #{next_cursor}"
end
members.each do |member|
Delayed::Job.enqueue(CollectPersonJob.new(member["id"],project_id,100000))
end
return members
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment