Created
January 20, 2015 14:32
-
-
Save intinig/54149ecfd2efe4a9934c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'lol' | |
| require 'redis' | |
| include Lol | |
| client = Client.new "foo", {region: ENV['API_REGION']} | |
| redis = Redis.new :url => ENV['REDIS_URL'] | |
| def fetch client, redis, slice | |
| return -1 if redis.llen("players") >= 50000 | |
| c = client.summoner.get slice | |
| results = c.select {|x| x.summoner_level == 30}.map {|y| h = "#{y.id},#{y.name}"; puts h; h} | |
| redis.rpush("players", results) if results != [] | |
| end | |
| threads = ThreadGroup.new | |
| (ENV['START'].to_i .. ENV['END'].to_i).each_slice(40) do |p_ids| | |
| sleep 1 while threads.list.size >= 100 | |
| thread = Thread.new { fetch client, redis, p_ids} | |
| threads.add thread | |
| thread.join | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment