[deploy] Index all readinglist Reactions into Elasticsearch (#7310)

This commit is contained in:
Molly Struve 2020-04-16 09:36:05 -05:00 committed by GitHub
parent 1024e47738
commit 01adfc377c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,11 @@
module DataUpdateScripts
class IndexReadingListReactions
def run
Reaction.readinglist.select(:id).in_batches do |batch|
Search::BulkIndexToElasticsearchWorker.set(queue: :default).perform_async(
"Reaction", batch.pluck(:id)
)
end
end
end
end

View file

@ -0,0 +1,18 @@
require "rails_helper"
require Rails.root.join("lib/data_update_scripts/20200415200651_index_reading_list_reactions.rb")
describe DataUpdateScripts::IndexReadingListReactions, elasticsearch: true do
it "indexes feed content(articles, comments, podcast episodes) to Elasticsearch" do
reactions = create_list(:reaction, 3, category: "readinglist")
Sidekiq::Worker.clear_all
reactions.each do |reaction|
expect { reaction.elasticsearch_doc }.to raise_error(Search::Errors::Transport::NotFound)
end
sidekiq_perform_enqueued_jobs { described_class.new.run }
reactions.each do |reaction|
expect(reaction.elasticsearch_doc).not_to be_nil
end
end
end