2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-12 21:10:47 +08:00

FEATURE: show tags in search results

This commit is contained in:
Neil Lalonde 2017-08-25 11:52:18 -04:00
parent cdcc5d6174
commit 2c56f8df7c
14 changed files with 162 additions and 2 deletions

View file

@ -8,6 +8,7 @@ module Jobs
rebuild_problem_posts
rebuild_problem_categories
rebuild_problem_users
rebuild_problem_tags
end

def rebuild_problem_categories(limit = 500)
@ -47,6 +48,15 @@ module Jobs
end
end

def rebuild_problem_tags(limit = 10000)
tag_ids = load_problem_tag_ids(limit)

tag_ids.each do |id|
tag = Tag.find_by(id: id)
SearchIndexer.index(tag, force: true) if tag
end
end

private

def load_problem_post_ids(limit)
@ -83,5 +93,13 @@ module Jobs
.limit(limit)
.pluck(:id)
end

def load_problem_tag_ids(limit)
Tag.joins(:tag_search_data)
.where('tag_search_data.locale != ?
OR tag_search_data.version != ?', SiteSetting.default_locale, Search::INDEX_VERSION)
.limit(limit)
.pluck(:id)
end
end
end