[deploy] Index Reaction created_at Timestamp (#10142)

This commit is contained in:
Molly Struve 2020-09-02 12:56:33 -05:00 committed by GitHub
parent 34593b7ec3
commit 83d44401f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 10 deletions

View file

@ -1,6 +1,6 @@
module Search
class ReactionSerializer < ApplicationSerializer
attributes :id, :category, :status, :user_id
attributes :id, :created_at, :category, :status, :user_id
attribute :reactable do |reaction|
reactable = reaction.reactable

View file

@ -7,6 +7,9 @@
"category": {
"type": "keyword"
},
"created_at": {
"type": "date"
},
"last_indexed_at": {
"type": "date"
},

View file

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

View file

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

View file

@ -1,7 +1,7 @@
require "rails_helper"
require Rails.root.join("lib/data_update_scripts/20200415200651_index_reading_list_reactions.rb")
require Rails.root.join("lib/data_update_scripts/20200901194251_reindex_reading_list_reactions.rb")
describe DataUpdateScripts::IndexReadingListReactions, elasticsearch: "Reaction" do
describe DataUpdateScripts::ReindexReadingListReactions, elasticsearch: "Reaction" do
it "indexes feed content(articles, comments, podcast episodes) to Elasticsearch" do
reactions = create_list(:reaction, 3, category: "readinglist")
Sidekiq::Worker.clear_all

View file

@ -13,7 +13,7 @@ RSpec.describe Search::ReactionSerializer do
user_data = Search::NestedUserSerializer.new(user).serializable_hash.dig(:data, :attributes)
expect(data_hash.dig(:reactable, :user)).to eq(user_data)
expect(data_hash[:reactable].keys).to include(:id, :body_text, :class_name, :path, :tags, :title)
expect(data_hash.keys).to include(:id, :category, :status, :user_id)
expect(data_hash.keys).to include(:id, :created_at, :category, :status, :user_id)
end
it "serializes a comment reaction" do
@ -21,7 +21,7 @@ RSpec.describe Search::ReactionSerializer do
user_data = Search::NestedUserSerializer.new(user).serializable_hash.dig(:data, :attributes)
expect(data_hash.dig(:reactable, :user)).to eq(user_data)
expect(data_hash[:reactable].keys).to include(:id, :body_text, :class_name, :path, :tags, :title)
expect(data_hash.keys).to include(:id, :category, :status, :user_id)
expect(data_hash.keys).to include(:id, :created_at, :category, :status, :user_id)
end
it "creates valid json for Elasticsearch" do