Skip to content

Commit

Permalink
- updating
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad Arimura committed Aug 12, 2011
1 parent 8e57440 commit fe78ad9
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 58 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ source 'http://rubygems.org'

gem 'rails', '3.0.7'

gem "mongoid", "~> 2.0"
gem "bson_ext", "~> 1.3"
gem "mongoid"
gem "bson_ext"

gem "twitter"
gem "simple_worker"
Expand Down
56 changes: 27 additions & 29 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,19 @@ GEM
activesupport (= 3.0.7)
activesupport (3.0.7)
addressable (2.2.6)
appoxy_api (0.0.11)
rest-client
arel (2.0.10)
bson (1.3.1)
bson_ext (1.3.1)
builder (2.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
faraday (0.6.1)
addressable (~> 2.2.4)
faraday (0.7.4)
addressable (~> 2.2.6)
multipart-post (~> 1.1.0)
rack (>= 1.1.0, < 2)
faraday_middleware (0.6.3)
faraday (~> 0.6.0)
hashie (1.0.0)
faraday_middleware (0.7.0)
faraday (~> 0.7.3)
hashie (1.1.0)
i18n (0.5.0)
mail (2.2.19)
activesupport (>= 2.3.6)
Expand All @@ -53,15 +51,16 @@ GEM
mime-types (1.16)
mongo (1.3.1)
bson (>= 1.3.1)
mongoid (2.0.2)
mongoid (2.0.0)
activemodel (~> 3.0)
mongo (~> 1.3)
mongo (~> 1.2)
tzinfo (~> 0.3.22)
multi_json (1.0.2)
will_paginate (~> 3.0.pre)
multi_json (1.0.3)
multi_xml (0.2.2)
multipart-post (1.1.1)
polyglot (0.3.1)
rack (1.2.2)
multipart-post (1.1.3)
polyglot (0.3.2)
rack (1.2.3)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
Expand All @@ -79,35 +78,34 @@ GEM
activesupport (= 3.0.7)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.9.0)
rash (0.3.0)
hashie (~> 1.0.0)
rest-client (1.6.1)
rake (0.9.2)
rest-client (1.6.3)
mime-types (>= 1.16)
simple_oauth (0.1.5)
simple_worker (0.5.8)
appoxy_api (>= 0.0.11)
simple_worker (0.7.4)
rest-client
zip
thor (0.14.6)
treetop (1.4.9)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
twitter (1.4.1)
faraday (~> 0.6.1)
faraday_middleware (~> 0.6.3)
hashie (~> 1.0.0)
twitter (1.6.2)
faraday (~> 0.7.4)
faraday_middleware (~> 0.7.0)
hashie (~> 1.1.0)
multi_json (~> 1.0.0)
multi_xml (~> 0.2.0)
rash (~> 0.3.0)
simple_oauth (~> 0.1.4)
tzinfo (0.3.27)
simple_oauth (~> 0.1.5)
tzinfo (0.3.29)
will_paginate (3.0.0)
zip (2.0.2)

PLATFORMS
ruby

DEPENDENCIES
bson_ext (~> 1.3)
mongoid (~> 2.0)
bson_ext
mongoid
rails (= 3.0.7)
rest-client
simple_worker
Expand Down
17 changes: 15 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
class UsersController < ApplicationController


def index
@users = User.all
end

def trim_users
i=0
y=0
User.all.each do |u|
if i > 100
u.destroy
y+=1
end
i+=1
end

render :text => "Deleted #{y} users"
end


def new
@user = User.new
Expand All @@ -28,5 +41,5 @@ def klout_score
render :text => u.klout_score
end


end
3 changes: 2 additions & 1 deletion app/views/twitter/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<%= link_to "Get Klout Score Serially", :action => "update_klout_serially" %> |
<%= link_to "Get Klout Score SimpleWorker", :action => "update_klout_parallel" %> |
<%= link_to "Delete Klout Scores", :action => "delete_klouts" %>
<%= link_to "Delete Klout Scores", :action => "delete_klouts" %> |
<%= link_to "Import Users into DB", :action => "import_users" %>

<br /><br />

Expand Down
2 changes: 1 addition & 1 deletion app/views/users/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1>Users</h1>

<% @users.each do |u| %>
<%= link_to u.first_name + " " + u.last_name, user_path(u.first_name) %><br />
<%= link_to u.first_name + " " + u.last_name, "#" %><br />
<% end %>

<br />
Expand Down
6 changes: 5 additions & 1 deletion app/workers/klout_batch_qb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def run
if users_chunk.size % 40 == 0
log "Creating worker with #{users_chunk.inspect}"

queue_kbw(users_chunk)
begin
queue_kbw(users_chunk)
rescue => ex
log "There was a problem --> #{ex}"
end

users_chunk = []
end
Expand Down
1 change: 1 addition & 0 deletions app/workers/klout_batch_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class KloutBatchWorker < SimpleWorker::Base

attr_accessor :users, :db_settings


def run
log "Running Klout Batch Worker"
init_mongohq
Expand Down
30 changes: 15 additions & 15 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@ class Application < Rails::Application
# Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += %W(#{Rails.root}/lib)

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)

# Configure the default encoding used in templates for Ruby 1.9.
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

# Configure sensitive parameters which will be filtered from the log file.
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
end
end
Expand Down
8 changes: 4 additions & 4 deletions config/mongoid.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
defaults: &defaults
host: flame.mongohq.com
port: 27102
host: dbh29.mongolab.com
port: 27297
username: webuser
password: mongosf1
database: learn
password: 123
database: mongosf

#defaults: &defaults
# host: localhost
Expand Down
5 changes: 2 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
Mongo1::Application.routes.draw do

match 'users/klout_score/:id' => 'users#klout_score'
match 'users/trim_users' => 'users#trim_users'

resources :users

root :to => "welcome#index"


match 'users/klout_score/:id' => 'users#klout_score'

match ':controller(/:action(/:id(.:format)))'


Expand Down

0 comments on commit fe78ad9

Please sign in to comment.