Skip to content

Commit 82359ea

Browse files
seurosvagrant
authored and
vagrant
committed
[Done][b125] Remove processing queues
1 parent 4ce1a1f commit 82359ea

12 files changed

+13
-191
lines changed

app/controllers/processing_queues_controller.rb

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

app/controllers/protips_controller.rb

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ProtipsController < ApplicationController
88
before_action :ensure_single_tag, only: [:subscribe, :unsubscribe]
99
before_action :limit_results, only: [:topic, :team, :search, :user, :date]
1010
before_action :track_search, only: [:search], unless: :is_admin?
11-
before_action :require_admin!, only: [:queue, :feature, :flag, :delete_tag, :admin]
11+
before_action :require_admin!, only: [:feature, :flag, :delete_tag, :admin]
1212
before_action :determine_scope, only: [:trending, :popular, :fresh, :liked]
1313
before_action :lookup_user_data, only: [:trending, :popular, :fresh, :liked, :search]
1414

@@ -322,28 +322,6 @@ def feature
322322
end
323323
end
324324

325-
def queue
326-
queue = params.permit(:queue)
327-
328-
respond_to do |format|
329-
if @protip && queue
330-
if ProcessingQueue.queued?(@protip, queue)
331-
ProcessingQueue.unqueue(@protip, queue)
332-
else
333-
queue_entry = ProcessingQueue.enqueue(@protip, queue)
334-
end
335-
else
336-
queue_entry = nil
337-
end
338-
339-
if queue_entry.nil?
340-
format.json { render status: :unprocessable_entity }
341-
else
342-
format.json { head :ok }
343-
end
344-
end
345-
end
346-
347325
def delete_tag
348326
@protip.topics.delete(CGI.unescape(params.permit(:topic)))
349327
respond_to do |format|

app/models/event.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ def generate_event(event_type, audience, data={}, drip_rate=:immediately)
1313
data = { version: VERSION, event_id: Time.now.utc.to_i }.with_indifferent_access.merge(data)
1414
data.deep_merge!(extra_information(data))
1515
drip_rate = :immediately if drip_rate.nil?
16-
send_admin_notifications(event_type, data, audience[:admin]) if audience.has_key? :admin
1716
channels = Audience.to_channels(audience)
1817
activity_feed_keys = channels.map { |channel| Audience.channel_to_key(channel) }
1918

@@ -32,16 +31,6 @@ def generate_event(event_type, audience, data={}, drip_rate=:immediately)
3231
end
3332
end
3433

35-
def send_admin_notifications(event_type, data, queue)
36-
unless queue.nil?
37-
if event_type.to_sym == :new_protip
38-
protip = Protip.with_public_id(data[:public_id])
39-
40-
ProcessingQueue.enqueue(protip, queue) unless protip.nil?
41-
end
42-
end
43-
end
44-
4534
def publish_event(channel, data)
4635
data.merge!(timestamp: Time.now.to_i)
4736
publish(channel, data.to_json)

app/models/processing_queue.rb

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

app/models/protip.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ class Protip < ActiveRecord::Base
7878

7979
# Begin these three lines fail the test
8080
after_save :index_search
81-
after_save :unqueue_flagged, if: :flagged?
8281
after_destroy :index_search_after_destroy
8382
after_create :update_network
8483
after_create :analyze_spam
@@ -100,7 +99,6 @@ class Protip < ActiveRecord::Base
10099
scope :with_upvotes, joins("INNER JOIN (#{Like.select('likable_id, SUM(likes.value) as upvotes').where(likable_type: 'Protip').group([:likable_type, :likable_id]).to_sql}) AS upvote_scores ON upvote_scores.likable_id=protips.id")
101100
scope :trending, order('score DESC')
102101
scope :flagged, where(flagged: true)
103-
scope :queued_for, ->(queue) { ProcessingQueue.queue_for_type(queue, self.class.name) }
104102

105103
class << self
106104

@@ -340,10 +338,6 @@ def index_search_after_destroy
340338
self.tire.update_index
341339
end
342340

343-
def unqueue_flagged
344-
ProcessingQueue.unqueue(self, :auto_tweet)
345-
end
346-
347341

348342
def networks
349343
Network.tagged_with(self.topics)
@@ -944,9 +938,6 @@ def total_views(epoch_since = 0)
944938
end
945939
end
946940

947-
def queued_for?(queue_name)
948-
ProcessingQueue.queued?(self, queue_name)
949-
end
950941

951942
def best_matching_job
952943
matching_jobs.first

app/views/admin/index.html.slim

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
li
99
i.fa.fa-comments
1010
=link_to 'comments', latest_comments_path
11-
li
12-
i.fa.fa-star
13-
= link_to 'featured', processing_queue_path(:auto_tweet)
14-
li
15-
i.fa.fa-hacker-news
16-
=link_to 'hackernews', processing_queue_path(:hackernews)
1711

1812
.widget-row
1913
.widget.green

app/views/processing_queues/index.html.haml

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

app/views/processing_queues/show.html.haml

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

app/views/protips/_protip.html.haml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
%ul.admin-links
5353
%li
5454
=link_to '', flag_protip_path(protip), :method => :post, :remote => true, :class => (protip.flagged? ? 'flagged' : "") + " flag"
55-
%li
56-
=link_to '', queue_protip_path(protip, :queue => 'hackernews'), :method => :post, :remote => true, :class => (protip.queued_for?(:hackernews) ? 'queued' : "") + " queue"
5755
%li
5856
=link_to '', feature_protip_path(protip), :method => :post, :remote => true, :class => (protip.featured? ? 'featured' : "") + " feature"
5957
%li

config/routes.rb

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# == Route Map
22
#
3+
# RAILS_ENV=development
4+
# Connecting to database specified by database.yml
5+
# Creating scope :near. Overwriting existing method TeamLocation.near.
6+
# GET /.json(.:format) #<Proc:0x0000000ce1f440@/vagrant/config/routes.rb:288>
7+
# GET /teams/.json(.:format) #<Proc:0x0000000ce1ccb8@/vagrant/config/routes.rb:289>
38
# protips_update GET|PUT /protips/update(.:format) protips#update
49
# protip_update GET|PUT /protip/update(.:format) protip#update
510
# root / protips#index
@@ -33,7 +38,6 @@
3338
# tag_protip POST /p/:id/tag(.:format) protips#tag {:id=>/[\dA-Z\-_]{6}/i}
3439
# flag_protip POST /p/:id/flag(.:format) protips#flag {:id=>/[\dA-Z\-_]{6}/i}
3540
# feature_protip POST /p/:id/feature(.:format) protips#feature {:id=>/[\dA-Z\-_]{6}/i}
36-
# queue_protip POST /p/:id/queue/:queue(.:format) protips#queue {:id=>/[\dA-Z\-_]{6}/i}
3741
# delete_tag_protip POST /p/:id/delete_tag/:topic(.:format) protips#delete_tag {:id=>/[\dA-Z\-_]{6}/i, :topic=>/[A-Za-z0-9#\$\+\-_\.(%23)(%24)(%2B)]+/}
3842
# like_protip_comment POST /p/:protip_id/comments/:id/like(.:format) comments#like {:id=>/\d+/, :protip_id=>/[\dA-Z\-_]{6}/i}
3943
# protip_comments GET /p/:protip_id/comments(.:format) comments#index {:id=>/\d+/, :protip_id=>/[\dA-Z\-_]{6}/i}
@@ -67,14 +71,6 @@
6771
# network GET /n/:id(.:format) networks#show {:slug=>/[\dA-Z\-]/i}
6872
# PUT /n/:id(.:format) networks#update {:slug=>/[\dA-Z\-]/i}
6973
# DELETE /n/:id(.:format) networks#destroy {:slug=>/[\dA-Z\-]/i}
70-
# dequeue_processing_queue POST /q/:id/dequeue/:item(.:format) processing_queues#dequeue
71-
# processing_queues GET /q(.:format) processing_queues#index
72-
# POST /q(.:format) processing_queues#create
73-
# new_processing_queue GET /q/new(.:format) processing_queues#new
74-
# edit_processing_queue GET /q/:id/edit(.:format) processing_queues#edit
75-
# processing_queue GET /q/:id(.:format) processing_queues#show
76-
# PUT /q/:id(.:format) processing_queues#update
77-
# DELETE /q/:id(.:format) processing_queues#destroy
7874
# protips GET /trending(.:format) protips#index
7975
# faq GET /faq(.:format) pages#show {:page=>:faq}
8076
# tos GET /tos(.:format) pages#show {:page=>:tos}
@@ -132,7 +128,7 @@
132128
# accept_team GET /teams/:id/accept(.:format) teams#accept
133129
# record_exit_team POST /teams/:id/record-exit(.:format) teams#record_exit
134130
# visitors_team GET /teams/:id/visitors(.:format) teams#visitors
135-
# follow_team POST /teams/:id/follow(.:format) follows#create {:type=>:team}
131+
# follow_team POST /teams/:id/follow(.:format) teams#follow
136132
# join_team POST /teams/:id/join(.:format) teams#join
137133
# approve_join_team POST /teams/:id/join/:user_id/approve(.:format) teams#approve_join
138134
# deny_join_team POST /teams/:id/join/:user_id/deny(.:format) teams#deny_join
@@ -266,20 +262,10 @@
266262
# callbacks_hawt_feature POST /callbacks/hawt/feature(.:format) callbacks/hawt#feature
267263
# callbacks_hawt_unfeature POST /callbacks/hawt/unfeature(.:format) callbacks/hawt#unfeature
268264
# admin_root GET /admin(.:format) admin#index
269-
# admin_failed_jobs GET /admin/failed_jobs(.:format) admin#failed_jobs
270265
# admin_teams GET /admin/teams(.:format) admin#teams
271266
# admin_sections_teams GET /admin/teams/sections/:num_sections(.:format) admin#sections_teams
272267
# admin_section_teams GET /admin/teams/section/:section(.:format) admin#section_teams
273268
# admin_sidekiq_web /admin/sidekiq Sidekiq::Web
274-
# /mail_view MailPreview
275-
# letter_opener_letters GET /letter_opener(.:format) letter_opener/letters#index
276-
# letter_opener_letter GET /letter_opener/:id/:style.html(.:format) letter_opener/letters#show
277-
# /campaigns Campaigns::Preview
278-
# /mail Notifier::Preview
279-
# /digest WeeklyDigest::Preview
280-
# /subscription Subscription::Preview
281-
# letter_opener_letters /letter_opener(.:format) letter_opener/letters#index
282-
# letter_opener_letter /letter_opener/:id/:style.html(.:format) letter_opener/letters#show
283269
#
284270

285271
Coderwall::Application.routes.draw do
@@ -332,7 +318,6 @@
332318
post 'tag'
333319
post 'flag'
334320
post 'feature'
335-
post 'queue/:queue' => 'protips#queue', as: :queue
336321
post 'delete_tag/:topic' => 'protips#delete_tag', as: :delete_tag, :topic => topic_regex
337322
end
338323
resources :comments, :constraints => {id: /\d+/} do
@@ -357,10 +342,6 @@
357342
end
358343
end
359344

360-
resources :processing_queues, :path => '/q' do
361-
member { post '/dequeue/:item' => 'processing_queues#dequeue', as: :dequeue }
362-
end
363-
364345
get 'trending' => 'protips#index', as: :protips
365346

366347
get 'faq' => 'pages#show', :page => :faq, as: :faq
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class DropProccessingQueue < ActiveRecord::Migration
2+
def up
3+
drop_table :processing_queues
4+
end
5+
end

db/schema.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended to check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(:version => 20140720121419) do
14+
ActiveRecord::Schema.define(:version => 20140726214006) do
1515

1616
create_table "alias_tags", :id => false, :force => true do |t|
1717
t.integer "tag_id"
@@ -227,14 +227,6 @@
227227
t.integer "interval_in_seconds", :default => 2592000
228228
end
229229

230-
create_table "processing_queues", :force => true do |t|
231-
t.integer "queueable_id"
232-
t.string "queueable_type"
233-
t.string "queue"
234-
t.datetime "queued_at"
235-
t.datetime "dequeued_at"
236-
end
237-
238230
create_table "protip_links", :force => true do |t|
239231
t.string "identifier"
240232
t.string "url"

0 commit comments

Comments
 (0)