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

This commit is contained in:
Guo Xiang Tan 2019-04-08 16:38:43 +08:00
parent b7d8bbc095
commit c4997ce85f
2 changed files with 8 additions and 5 deletions

View File

@ -95,9 +95,8 @@ module Jobs
ON pd.locale = :locale ON pd.locale = :locale
AND pd.version = :version AND pd.version = :version
AND pd.post_id = posts.id 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 WHERE pd.post_id IS NULL
AND topics.id IS NOT NULL
AND topics.deleted_at IS NULL AND topics.deleted_at IS NULL
AND posts.raw != '' AND posts.raw != ''
ORDER BY posts.id DESC ORDER BY posts.id DESC

View File

@ -49,12 +49,16 @@ describe Jobs::ReindexSearch do
FakeIndexer.reset FakeIndexer.reset
end 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) post = Fabricate(:post)
post2 = Fabricate(:post) post2 = Fabricate(:post)
post.post_search_data.destroy! post3 = Fabricate(:post)
post2.post_search_data.destroy! PostSearchData.delete_all
post2.topic.trash! post2.topic.trash!
post3.trash!
subject.rebuild_problem_posts(indexer: FakeIndexer) subject.rebuild_problem_posts(indexer: FakeIndexer)