Skip to content

Commit c28534f

Browse files
committed
[WIP][Broken][ci skip] Drop resque
1 parent 97d0a1f commit c28534f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+260
-446
lines changed

Gemfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ gem 'chronic'
6868
# Redis
6969
gem 'redis-rails' , '~> 3.2'
7070

71-
# Background Job Processing
72-
gem 'resque'
73-
gem 'resque-scheduler'
74-
gem 'resque_mailer'
7571

7672
gem 'sidekiq'
7773
gem 'sinatra'
@@ -171,7 +167,6 @@ group :test do
171167
gem 'capybara'
172168
gem 'database_cleaner'
173169
gem 'fuubar' , '2.0.0.rc1'
174-
gem 'resque_spec'
175170
gem 'simplecov'
176171
gem 'timecop'
177172
gem 'vcr'
@@ -182,7 +177,6 @@ end
182177
group :production do
183178
gem 'airbrake'
184179
gem 'heroku_rails_deflate'
185-
gem 'newrelic_resque_agent'
186180
gem 'newrelic_rpm'
187181
gem 'puma'
188182
gem 'rails_12factor'

Procfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
web: bundle exec puma -C ./config/puma.rb
2-
worker: env QUEUE=CRITICAL,HIGH,MEDIUM,LOW,LOWER bundle exec rake resque:work
3-
scheduler: bundle exec rake resque:scheduler
4-
refresher: env QUEUE=REFRESH bundle exec rake resque:work
5-
mailer: env QUEUE=mailer,digest_mailer bundle exec rake resque:work
62
sidekiq: bundle exec sidekiq -C ./config/sidekiq.yml

app/controllers/application_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def show_achievement
123123
def record_visit
124124
if viewing_user
125125
if viewing_user == current_user && (viewing_user.try(:last_request_at) || 1.week.ago) < 1.day.ago && viewing_user.active? && viewing_user.last_refresh_at < 2.days.ago
126-
Resque.enqueue(RefreshUser, current_user.username)
126+
RefreshUserJob.perform_async(current_user.username)
127127
end
128128
viewing_user.visited!
129129
Usage.page_view(viewing_user.id) unless viewing_user.admin?
@@ -132,7 +132,7 @@ def record_visit
132132

133133
def record_location
134134
if viewing_user && viewing_user.ip_lat.nil? && deployment_environment?
135-
Resque.enqueue(ReverseGeolocateUser, viewing_user.username, request.ip)
135+
ReverseGeolocateUserJob.perform_async(viewing_user.username, request.ip)
136136
end
137137
end
138138

@@ -243,7 +243,7 @@ def record_event(action_name, options = {})
243243
#options.merge!('signed up on' => current_user.created_at.to_formatted_s(:mixpanel),
244244
# 'achievements' => current_user.badges_count) if signed_in?
245245

246-
Resque.enqueue(MixpanelTracker::TrackEventJob, action_name, options, request.ip) if ENABLE_TRACKING
246+
TrackEventJob.perform_async(action_name, options, request.ip) if ENABLE_TRACKING
247247
end
248248
rescue Exception => ex
249249
Rails.logger.error("MIXPANEL: Swallowing error when trying to record #{action_name}, #{ex.message}")

app/controllers/redemptions_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def show
66
if current_user.pending?
77
current_user.activate!
88
Notifier.welcome_email(current_user.username).deliver
9-
Resque.enqueue(RefreshUser, current_user.username)
9+
RefreshUserJob.perform_async(current_user.username)
1010
end
1111
redirect_to(destination_url)
1212
else

app/controllers/users_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def refresh
158158

159159
refresh_params = params.permit(:username)
160160

161-
Resque.enqueue(RefreshUser, refresh_params[:username], true)
161+
RefreshUserJob.perform_async(refresh_params[:username], true)
162162
flash[:notice] = "Queued #{refresh_params[:username]} for a refresh"
163163
redirect_to :back
164164
end

app/jobs/activate_user.rb

Lines changed: 0 additions & 26 deletions
This file was deleted.

app/jobs/activate_user_job.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class ActivateUserJob
2+
include Sidekiq::Worker
3+
sidekiq_options queue: :high
4+
5+
def perform(username, always_activate=true)
6+
user = User.find_by_username(username)
7+
return if user.active? || always_activate
8+
RefreshUserJob.new.perform(username)
9+
unless user.badges.empty?
10+
user.activate!
11+
Notifier.welcome_email(username).deliver
12+
end
13+
end
14+
end

app/jobs/analyze_spam.rb

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/jobs/analyze_spam_job.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class AnalyzeSpamJob
2+
include Sidekiq::Worker
3+
4+
sidekiq_options queue: :medium
5+
6+
def perform(spammable)
7+
thing_to_analyze = spammable['klass'].classify.constantize.find(spammable['id'])
8+
9+
if thing_to_analyze.spam?
10+
thing_to_analyze.create_spam_report
11+
end
12+
end
13+
end

app/jobs/analyze_user.rb renamed to app/jobs/analyze_user_job.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
class AnalyzeUser < Struct.new(:username)
2-
extend ResqueSupport::Basic
1+
class AnalyzeUserJob
2+
include Sidekiq::Worker
33

4-
@queue = 'HIGH'
4+
sidekiq_options queue: :high
55

6-
def perform
6+
def perform(username)
77
user = User.find_by_username(username)
88
unless user.twitter.nil?
99
RestClient.get "#{ENV['TWITTER_ANALYZER_URL']}/#{user.username}/#{user.twitter}"

app/jobs/assign_networks.rb renamed to app/jobs/assign_networks_job.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
class AssignNetworks < Struct.new(:username)
2-
extend ResqueSupport::Basic
1+
class AssignNetworksJob
2+
include Sidekiq::Worker
33

4-
@queue = 'LOW'
4+
sidekiq_options queue: :low
55

6-
def perform
6+
def perform(username)
77
user = User.find_by_username(username)
88
user.skills.map(&:name).each do |skill|
99
Network.all_with_tag(skill).each do |network|

app/jobs/award.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/jobs/award_job.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class AwardJob
2+
include Sidekiq::Worker
3+
include Awards
4+
5+
sidekiq_options queue: :high
6+
7+
def perform(badge, date, provider, candidate)
8+
award(badge.constantize, date, provider, candidate)
9+
end
10+
end

app/jobs/award_user.rb renamed to app/jobs/award_user_job.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
class AwardUser < Struct.new(:username, :badges)
2-
extend ResqueSupport::Basic
1+
class AwardUserJob
2+
include Sidekiq::Worker
33

4-
@queue = 'LOW'
4+
sidekiq_options queue: :low
55

6-
def perform
6+
def perform(username, badges)
77
user = User.find_by_username(username)
88

99
if badges.first.is_a?(String)

app/jobs/build_activity_stream.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/jobs/build_activity_stream_job.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class BuildActivityStreamJob
2+
include Sidekiq::Worker
3+
4+
sidekiq_options queue: :medium
5+
6+
def perform(username)
7+
user = User.find_by_username(username)
8+
user.build_repo_followed_activity!
9+
end
10+
end

app/jobs/build_bio_and_joined_dates.rb renamed to app/jobs/build_bio_and_joined_dates_job.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
class BuildBioAndJoinedDates < Struct.new(:username)
2-
extend ResqueSupport::Basic
1+
class BuildBioAndJoinedDatesJob
2+
include Sidekiq::Worker
33

4-
@queue = 'HIGH'
4+
sidekiq_options queue: :high
55

6-
def perform
6+
def perform(username)
77
user = User.find_by_username(username)
88
unless user.github.blank? && user.joined_github_on.blank?
99
user.joined_github_on = (user.send(:load_github_profile) || {})[:created_at]

app/jobs/create_network.rb renamed to app/jobs/create_network_job.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
class CreateNetwork < Struct.new(:tag)
2-
extend ResqueSupport::Basic
1+
class CreateNetworkJob
2+
include Sidekiq::Worker
33

4-
@queue = 'LOW'
4+
sidekiq_options queue: :low
55

6-
def perform
6+
def perform(tag)
77
top_tags = Protip.trending_topics
88
sub_tags = Protip.tagged_with([tag], on: :topics).collect(&:topics).flatten
99
sub_tags.delete_if { |sub_tag| top_tags.include? sub_tag }

app/jobs/deactivate_team_jobs.rb

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/jobs/deactivate_team_jobs_job.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class DeactivateTeamJobsJob
2+
include Sidekiq::Worker
3+
4+
sidekiq_options queue: :low
5+
6+
def perform(id)
7+
team = Team.find(id)
8+
team.jobs.each do |job|
9+
job.deactivate!
10+
end
11+
end
12+
13+
end

app/jobs/generate_top_users_composite.rb renamed to app/jobs/generate_top_users_composite_job.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
class GenerateTopUsersComposite
2-
extend ResqueSupport::Basic
1+
class GenerateTopUsersCompositeJob
2+
include Sidekiq::Worker
33

44
IMAGE_PATH = Rails.root.join('public', 'images', 'top')
55
WALL_IMAGE = IMAGE_PATH.join("wall.png")

app/jobs/geolocate.rb renamed to app/jobs/geolocate_job.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
class Geolocate
2-
extend ResqueSupport::Basic
1+
class GeolocateJob
2+
include Sidekiq::Worker
33

4-
@queue = 'LOW'
4+
sidekiq_options queue: :low
55

66
def perform
77
User.active.not_geocoded.each do |user|

app/jobs/import_protip.rb renamed to app/jobs/import_protip_job.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
class ImportProtip < Struct.new(:type, :arg1)
2-
extend ResqueSupport::Basic
1+
class ImportProtip
2+
include Sidekiq::Worker
33

4-
@queue = 'LOW'
4+
sidekiq_options queue: :low
55

6-
def perform
7-
case type.to_sym
8-
when :github_follows
6+
def perform(type, arg1)
7+
case type
8+
when 'github_follows'
99
import_github_follows(arg1)
10-
when :slideshare
10+
when 'slideshare'
1111
import_slideshares(arg1)
12-
when :subscriptions
12+
when 'subscriptions'
1313
autosubscribe_users(arg1)
1414
end
1515
end
@@ -20,7 +20,7 @@ def import_github_follows(username)
2020
end
2121

2222
def import_slideshares(fact_id)
23-
fact = Fact.find(fact_id)
23+
Fact.find(fact_id)
2424
#Importers::Protips::SlideshareImporter.import_from_fact(fact)
2525
end
2626

app/jobs/index_team.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/jobs/index_team_job.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class IndexTeamJob
2+
include Sidekiq::Worker
3+
4+
sidekiq_options queue: :high
5+
6+
def perform(team_id)
7+
team = Team.find(team_id)
8+
team.tire.update_index
9+
end
10+
end

app/jobs/merge_duplicate_link.rb renamed to app/jobs/merge_duplicate_link_job.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
class MergeDuplicateLink < Struct.new(:link)
2-
extend ResqueSupport::Basic
1+
class MergeDuplicateLinkJob
2+
include Sidekiq::Worker
33

4-
@queue = 'LOW'
4+
sidekiq_options queue: :low
55

6-
def perform
6+
def perform(link)
77
all_links = ProtipLink.where(url: link).order('created_at ASC')
88
protip_to_keep = all_links.shift.protip
99
#merge

0 commit comments

Comments
 (0)