Skip to content

Commit

Permalink
PERF: improve performance of emoji grants
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSaffron committed Apr 12, 2016
1 parent 983d64f commit 144bf07
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/jobs/onceoff/grant_emoji.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ class GrantEmoji < Jobs::Onceoff
def execute_onceoff(args)
to_award = {}

Post.secured(Guardian.new).visible.public_posts.find_in_batches do |group|
Post.secured(Guardian.new)
.select(:id, :created_at, :cooked, :user_id)
.visible
.public_posts
.where("cooked like '%emoji%'")
.find_in_batches do |group|
group.each do |p|
doc = Nokogiri::HTML::fragment(p.cooked)
if (doc.css("img.emoji") - doc.css(".quote img")).size > 0
Expand Down

0 comments on commit 144bf07

Please sign in to comment.