Skip to content

A platform for community discussion. Free, open, simple.

FIX: Don't try and reindex posts that have been trashed.

Guo Xiang Tanc4997ce85f5b
diff --git a/app/jobs/scheduled/reindex_search.rb b/app/jobs/scheduled/reindex_search.rb
index 1a15ec5dd5b..5a1c784e20a 100644
--- a/app/jobs/scheduled/reindex_search.rb
+++ b/app/jobs/scheduled/reindex_search.rb
@@ -95,9 +95,8 @@ module Jobs
ON pd.locale = :locale
AND pd.version = :version
AND pd.post_id = posts.id
- LEFT JOIN topics ON topics.id = posts.topic_id
+ INNER JOIN topics ON topics.id = posts.topic_id
WHERE pd.post_id IS NULL
- AND topics.id IS NOT NULL
AND topics.deleted_at IS NULL
AND posts.raw != ''
ORDER BY posts.id DESC
diff --git a/spec/jobs/reindex_search_spec.rb b/spec/jobs/reindex_search_spec.rb
index df634663917..bc6b3f6efa5 100644
--- a/spec/jobs/reindex_search_spec.rb
+++ b/spec/jobs/reindex_search_spec.rb
@@ -49,12 +49,16 @@ describe Jobs::ReindexSearch do
FakeIndexer.reset
end
- it 'should not reinex posts that belong to a deleted topic' do
+ it (
+ 'should not reindex posts that belong to a deleted topic ' \
+ 'or have been trashed'
+ ) do
post = Fabricate(:post)
post2 = Fabricate(:post)
- post.post_search_data.destroy!
- post2.post_search_data.destroy!
+ post3 = Fabricate(:post)
+ PostSearchData.delete_all
post2.topic.trash!
+ post3.trash!
subject.rebuild_problem_posts(indexer: FakeIndexer)