Bug Fix:Fix Data Update feed_source_url Script (#10253)

This commit is contained in:
Molly Struve 2020-09-08 16:15:05 -05:00 committed by GitHub
parent e2d43c4a73
commit c71f179b28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,7 @@ module DataUpdateScripts
# This statement deletes all draft articles in excess found to be duplicate over feed_source_url,
# excluding those whose body_markdown is different from the other duplicate occurrences
result_same_body = ActiveRecord::Base.connection.execute(
<<~SQL,
<<~SQL.squish,
WITH duplicates_draft_articles AS
(SELECT id
FROM
@ -33,7 +33,7 @@ module DataUpdateScripts
# with different bodies.
# We thus select the oldest for removal preserving the most recent one
result_different_bodies = ActiveRecord::Base.connection.execute(
<<~SQL,
<<~SQL.squish,
WITH duplicates_draft_articles AS
(SELECT id
FROM
@ -61,7 +61,7 @@ module DataUpdateScripts
# Remove all articles from Elasticsearch
(result_same_body_ids + result_different_bodies_ids).each do |id|
Search::RemoveFromIndexWorker.perform_in(5.seconds, "Article", id)
Search::RemoveFromIndexWorker.perform_in(5.seconds, "Search::FeedContent", "article_#{id}")
end
# Store deleted IDs temporarily in Redis for safe keeping