[deploy] Index Reaction created_at Timestamp (#10142)
This commit is contained in:
parent
34593b7ec3
commit
83d44401f5
6 changed files with 24 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
"category": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "date"
|
||||
},
|
||||
"last_indexed_at": {
|
||||
"type": "date"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue