Add tags overlap field

This information is already available, so there's no extra processing.
To avoid conflicting with the current tags field, it was made into its
own field, and it uses a hash so that values can be quickly looked up.
This commit is contained in:
BrokenEagle
2020-03-06 06:42:05 +00:00
parent cded0f763b
commit 2d669899a4

View File

@@ -26,6 +26,14 @@ class RelatedTagQuery
end
end
def tags_overlap
if query =~ /\*/
{}
else
tags.map { |v| [v.name, v.overlap_count] }.to_h
end
end
# Returns the top 20 most frequently added tags within the last 20 edits made by the user in the last hour.
def recent_tags(since: 1.hour.ago, max_edits: 20, max_tags: 20)
return [] unless user.present? && PostVersion.enabled?
@@ -78,6 +86,7 @@ class RelatedTagQuery
query: query,
category: category,
tags: tags_with_categories(tags.map(&:name)),
tags_overlap: tags_overlap,
wiki_page_tags: tags_with_categories(wiki_page_tags),
other_wikis: other_wiki_pages.map { |wiki| [wiki.title, tags_with_categories(wiki.tags)] }.to_h
}