PERF: improve performance of emoji grants

This commit is contained in:
Sam 2016-04-12 22:07:55 +10:00
parent 983d64fd56
commit 144bf07886
1 changed files with 6 additions and 1 deletions

View File

@ -6,7 +6,12 @@ module Jobs
def execute_onceoff(args) def execute_onceoff(args)
to_award = {} 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| group.each do |p|
doc = Nokogiri::HTML::fragment(p.cooked) doc = Nokogiri::HTML::fragment(p.cooked)
if (doc.css("img.emoji") - doc.css(".quote img")).size > 0 if (doc.css("img.emoji") - doc.css(".quote img")).size > 0