Skip to content

Commit

Permalink
Merge branch 'develop' into feature/CV2-5067-CV2-4979-export-list
Browse files Browse the repository at this point in the history
  • Loading branch information
caiosba committed Aug 21, 2024
2 parents 6a16173 + 8b36ea4 commit d46c869
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
30 changes: 17 additions & 13 deletions config/initializers/report_designer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/tasks/check_khousheh.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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
Expand All @@ -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."
Expand Down

0 comments on commit d46c869

Please sign in to comment.