Merge branch 'search-suggestions'
This commit is contained in:
@@ -69,6 +69,10 @@ module PostSets
|
|||||||
tag_string =~ /\*/
|
tag_string =~ /\*/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_empty_search?
|
||||||
|
posts.count == 0
|
||||||
|
end
|
||||||
|
|
||||||
def current_page
|
def current_page
|
||||||
[page.to_i, 1].max
|
[page.to_i, 1].max
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ module PostSetPresenters
|
|||||||
end
|
end
|
||||||
|
|
||||||
def related_tags
|
def related_tags
|
||||||
if post_set.is_pattern_search?
|
if post_set.is_empty_search?
|
||||||
|
suggested_tags
|
||||||
|
elsif post_set.is_pattern_search?
|
||||||
pattern_tags
|
pattern_tags
|
||||||
elsif post_set.is_tag_subscription?
|
elsif post_set.is_tag_subscription?
|
||||||
post_set.tag_subscription_tags
|
post_set.tag_subscription_tags
|
||||||
@@ -39,6 +41,12 @@ module PostSetPresenters
|
|||||||
Tag.name_matches(post_set.tag_string).all(:select => "name", :limit => Danbooru.config.tag_query_limit, :order => "post_count DESC").map(&:name)
|
Tag.name_matches(post_set.tag_string).all(:select => "name", :limit => Danbooru.config.tag_query_limit, :order => "post_count DESC").map(&:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def suggested_tags
|
||||||
|
if post_set.tag_string.length >= 3
|
||||||
|
Tag.name_matches("*#{post_set.tag_string}*").where("post_count > 0").all(:select => "name", :limit => Danbooru.config.tag_query_limit, :order => "post_count DESC").map(&:name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def related_tags_for_group
|
def related_tags_for_group
|
||||||
RelatedTagCalculator.calculate_from_sample_to_array(post_set.tag_string).map(&:first)
|
RelatedTagCalculator.calculate_from_sample_to_array(post_set.tag_string).map(&:first)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user