fix the build

This commit is contained in:
Régis Hanol 2015-03-30 12:48:20 +02:00
parent 588667b1e4
commit 10b8eca9a6
2 changed files with 4 additions and 3 deletions

View file

@ -2,8 +2,7 @@ module Jobs
class FixAvatarInQuotes < Jobs::Base
def execute(args)
user = User.find(args[:user_id])
post_ids_to_rebake = Post.exec_sql("SELECT post_id FROM quoted_posts WHERE quoted_post_id IN (SELECT id FROM posts WHERE user_id = ?)", user.id).values.flatten.map(&:to_i)
post_ids_to_rebake = Post.exec_sql("SELECT post_id FROM quoted_posts WHERE quoted_post_id IN (SELECT id FROM posts WHERE user_id = ?)", args[:user_id]).values.flatten.map(&:to_i)
Post.where(id: post_ids_to_rebake).find_each.map(&:rebake!)
end

View file

@ -646,7 +646,9 @@ class User < ActiveRecord::Base
Jobs.enqueue(:update_gravatar, user_id: self.id, avatar_id: avatar.id)
end
Jobs.enqueue(:fix_avatar_in_quotes, user_id: self.id)
if self.uploaded_avatar_id_changed?
Jobs.enqueue(:fix_avatar_in_quotes, user_id: self.id)
end
end
def first_post_created_at