Use activerecord-import in ReceiveLocalBatch. The default behavior of it is to do an On Duplicate Key Update updated_at = Time.now, but we have a test for that case anyway.

This commit is contained in:
Raphael Sofaer 2011-07-14 16:57:17 -07:00
parent 088e2dfdb4
commit 37e939d476

View file

@ -16,14 +16,10 @@ module Job
end
def self.create_visibilities(post, recipient_user_ids)
contacts = Contact.where(:user_id => recipient_user_ids, :person_id => post.author_id)
contacts.each do |contact|
begin
PostVisibility.create(:contact_id => contact.id, :post_id => post.id)
rescue ActiveRecord::RecordNotUnique => e
Rails.logger.info(:event => :unexpected_pv, :contact_id => contact.id, :post_id => post.id)
#The post was already visible to that user
end
new_post_visibilities = contacts.map do |contact|
PostVisibility.new(:contact_id => contact.id, :post_id => post.id)
end
PostVisibility.import new_post_visibilities
end
def self.socket_to_users(post, recipient_user_ids)
recipient_user_ids.each do |id|