Skip to content

Commit

Permalink
latest stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
carimura committed Sep 24, 2012
1 parent 27b64fd commit 12bf65e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.rbc
.bundle
.config
.idea
coverage
InstalledFiles
lib/bundler/man
Expand All @@ -11,6 +12,9 @@ spec/reports
test/tmp
test/version_tmp
tmp
iron.json
run.rb


# YARD artifacts
.yardoc
Expand Down
26 changes: 26 additions & 0 deletions koder_master.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'iron_worker_ng'
require 'iron_cache'
require 'rest'
require 'json'

options = {}
url = "https://api.stackexchange.com/2.1/users?order=desc&sort=reputation&site=stackoverflow"
rest = Rest::Client.new(:gem => :typhoeus)
cache = IronCache::Client.new(:token => params[:token], :project_id => params[:project_id])
worker = IronWorkerNG::Client.new(:token => params[:token], :project_id => params[:project_id])

koders = cache.cache("koders")
user_ids = []

res = rest.get(url, options)
results = JSON.parse(res.body)

results["items"].each do |i|
puts "Found user #{i["display_name"]}"
koders.put(i["user_id"].to_s, i.to_s)
user_ids << i["user_id"]

worker.tasks.create("koder_slave", :user_id => i["user_id"])
end

puts "Processed #{user_ids.size} users"
7 changes: 7 additions & 0 deletions koder_master.worker
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
runtime "ruby"
exec "koder_master.rb"

gem "rest"
gem "iron_cache"
gem "iron_worker_ng"
gem "json"
3 changes: 3 additions & 0 deletions koder_slave.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

puts "Got id --> #{params[:user_id]}"

4 changes: 4 additions & 0 deletions koder_slave.worker
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
runtime "ruby"
exec "koder_slave.rb"

gem "json"

0 comments on commit 12bf65e

Please sign in to comment.