Commit 9c8bf31e3d81183119b45836453e4fb436834278

Authored by Andrew Kane
1 parent e60ff0b9

Use update_all in example [skip ci]

Showing 1 changed file with 7 additions and 3 deletions   Show diff stats
@@ -1648,11 +1648,15 @@ class ReindexConversionsJob < ApplicationJob @@ -1648,11 +1648,15 @@ class ReindexConversionsJob < ApplicationJob
1648 end 1648 end
1649 1649
1650 # write to cache 1650 # write to cache
1651 - attributes = conversions_by_record.map { |k, v| {id: k, search_conversions: v} }  
1652 - class_name.constantize.upsert_all(attributes) 1651 + model = class_name.constantize
  1652 + model.transaction do
  1653 + conversions_by_record.each do |id, conversions|
  1654 + model.where(id: id).update_all(search_conversions: conversions)
  1655 + end
  1656 + end
1653 1657
1654 # partial reindex 1658 # partial reindex
1655 - class_name.constantize.where(id: ids).reindex(:search_conversions_data) 1659 + model.where(id: ids).reindex(:search_conversions_data)
1656 end 1660 end
1657 end 1661 end
1658 end 1662 end