Skip to content
Newer
Older
100644 47 lines (35 sloc) 1.05 KB
12bf65e @carimura latest stuffs
carimura authored Sep 23, 2012
1 require 'iron_worker_ng'
2 require 'iron_cache'
3 require 'rest'
3a93fc4 @treeder Shows little profile of users.
treeder authored Sep 24, 2012
4 require 'uber_config'
5
6 begin
7 @config = UberConfig.load
8 UberConfig.symbolize_keys!(@config)
9 rescue => ex
10 puts "Using params for config"
11 @config = params
12 end
13
14 #puts "config:"
15 #p @config
12bf65e @carimura latest stuffs
carimura authored Sep 24, 2012
16
3a93fc4 @treeder Shows little profile of users.
treeder authored Sep 24, 2012
17 rest = Rest::Client.new
18 cache = IronCache::Client.new(@config[:iron])
19 worker = IronWorkerNG::Client.new(@config[:iron])
12bf65e @carimura latest stuffs
carimura authored Sep 24, 2012
20
21 koders = cache.cache("koders")
22 user_ids = []
23
5e4f8bf @treeder Fixed some final issues.
treeder authored Sep 24, 2012
24 pages = 5
25 pagesize = 100
12bf65e @carimura latest stuffs
carimura authored Sep 24, 2012
26
80db060 @carimura latest stuffs
carimura authored Sep 23, 2012
27 pages.downto(1) do |p|
32a4819 @carimura stuffs
carimura authored Sep 23, 2012
28 url = "https://api.stackexchange.com/2.1/users?pagesize=#{pagesize}&order=desc&sort=reputation&site=stackoverflow&page=#{p}"
80db060 @carimura latest stuffs
carimura authored Sep 24, 2012
29 res = rest.get(url)
30 results = JSON.parse(res.body)
12bf65e @carimura latest stuffs
carimura authored Sep 24, 2012
31
80db060 @carimura latest stuffs
carimura authored Sep 24, 2012
32 results["items"].each do |i|
e362ec9 @carimura new stuffs
carimura authored Sep 23, 2012
33 #puts "Found user #{i["display_name"]}"
32a4819 @carimura stuffs
carimura authored Sep 24, 2012
34 koders.put(i["user_id"].to_s, i.to_json)
80db060 @carimura latest stuffs
carimura authored Sep 24, 2012
35 user_ids << i["user_id"]
36
32a4819 @carimura stuffs
carimura authored Sep 24, 2012
37 worker.tasks.create("koder_slave", {:user_id => i["user_id"],
3a93fc4 @treeder Shows little profile of users.
treeder authored Sep 24, 2012
38 :name => i["display_name"]}.merge(@config))
80db060 @carimura latest stuffs
carimura authored Sep 24, 2012
39 end
12bf65e @carimura latest stuffs
carimura authored Sep 24, 2012
40
e362ec9 @carimura new stuffs
carimura authored Sep 24, 2012
41 puts "Results --> #{results}"
42 end
80db060 @carimura latest stuffs
carimura authored Sep 24, 2012
43
3a93fc4 @treeder Shows little profile of users.
treeder authored Sep 24, 2012
44 koders.put("user_list", user_ids.to_json)
32a4819 @carimura stuffs
carimura authored Sep 24, 2012
45
12bf65e @carimura latest stuffs
carimura authored Sep 24, 2012
46 puts "Processed #{user_ids.size} users"
Something went wrong with that request. Please try again.