diff --git a/config/initializers/report_designer.rb b/config/initializers/report_designer.rb index 08cd3dcbf8..ffbf4d7d2b 100644 --- a/config/initializers/report_designer.rb +++ b/config/initializers/report_designer.rb @@ -50,9 +50,11 @@ if fc.nil? FactCheck.create({ claim_description: pm.claim_description }.merge(fields)) else - fields.each { |field, value| fc.send("#{field}=", value) } - fc.skip_check_ability = true - fc.save! + PaperTrail.request(enabled: false) do + fields.each { |field, value| fc.send("#{field}=", value) } + fc.skip_check_ability = true + fc.save! + end end end @@ -66,16 +68,18 @@ # Update report fields fc = pm&.claim_description&.fact_check unless fc.nil? - state = self.data['state'] - fields = { - skip_report_update: true, - publisher_id: nil, - report_status: state, - rating: pm.status - } - fields.each { |field, value| fc.send("#{field}=", value) } - fc.skip_check_ability = true - fc.save! + PaperTrail.request(enabled: false) do + state = self.data['state'] + fields = { + skip_report_update: true, + publisher_id: nil, + report_status: state, + rating: pm.status + } + fields.each { |field, value| fc.send("#{field}=", value) } + fc.skip_check_ability = true + fc.save! + end end end end diff --git a/lib/tasks/check_khousheh.rake b/lib/tasks/check_khousheh.rake index ee1f299c65..098d9f3c06 100644 --- a/lib/tasks/check_khousheh.rake +++ b/lib/tasks/check_khousheh.rake @@ -192,6 +192,8 @@ namespace :check do Cluster.transaction do # Create clusters mapping = {} # Media ID => Cluster ID + # Cluster to delete in case there is no center (project_media_id) + cluster_to_delete = [] # Bulk-insert clusters c_inserted_items = [] clusters.length.times.each_slice(2500) do |rows| @@ -278,6 +280,7 @@ namespace :check do updated_cluster_attributes[:title] = cluster_title # Update cluster if updated_cluster_attributes[:project_media_id].blank? + cluster_to_delete << cluster.id error_logs << {Cluster: "Failed to update Cluster with id #{cluster.id}"} else cluster_items[cluster.id] = updated_cluster_attributes @@ -303,6 +306,8 @@ namespace :check do end search_after = [pm_ids.max] end + # Delete cluster with no project_media_id + Cluster.where(id: cluster_to_delete).delete_all Team.current = nil end puts "\nRebuilding clusters for feed #{feed.name} took #{Time.now.to_f - started_at} seconds."