DEV: Allow developmental post search index versions.

This commit is contained in:
Guo Xiang Tan 2020-07-23 14:52:20 +08:00
parent fe71c43c57
commit 3766122a82
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
3 changed files with 11 additions and 2 deletions

View File

@ -140,7 +140,7 @@ module Jobs
def load_problem_post_ids(limit)
params = {
locale: SiteSetting.default_locale,
version: SearchIndexer::POST_INDEX_VERSION,
version: SearchIndexer::MIN_POST_REINDEX_VERSION,
limit: limit
}
@ -151,7 +151,7 @@ module Jobs
JOIN topics ON topics.id = posts.topic_id
LEFT JOIN post_search_data pd
ON pd.locale = :locale
AND pd.version = :version
AND pd.version >= :version
AND pd.post_id = posts.id
WHERE pd.post_id IS NULL
AND posts.deleted_at IS NULL

View File

@ -2,6 +2,7 @@
class SearchIndexer
POST_INDEX_VERSION = 3
MIN_POST_REINDEX_VERSION = 3
TOPIC_INDEX_VERSION = 3
CATEGORY_INDEX_VERSION = 3
USER_INDEX_VERSION = 3

View File

@ -68,6 +68,14 @@ describe Jobs::ReindexSearch do
expect(FakeIndexer.posts).to contain_exactly(post)
end
it 'should not reindex posts with a developmental version' do
post = Fabricate(:post, version: SearchIndexer::MIN_POST_REINDEX_VERSION + 1)
subject.rebuild_problem_posts(indexer: FakeIndexer)
expect(FakeIndexer.posts).to eq([])
end
it 'should not reindex posts with empty raw' do
post = Fabricate(:post)
post.post_search_data.destroy!