add references to user statistics page about saved searches
This commit is contained in:
@@ -8,7 +8,7 @@ class PopularSearchService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def each_search(limit = 100, &block)
|
def each_search(limit = 100, &block)
|
||||||
fetch_data.scan(/(.+?) (\d+)\.0\n/).slice(0, limit).each(&block)
|
fetch_data.to_s.scan(/(.+?) (\d+)\.0\n/).slice(0, limit).each(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_data
|
def fetch_data
|
||||||
|
|||||||
@@ -132,6 +132,10 @@ class SavedSearch < ActiveRecord::Base
|
|||||||
rename_listbooru(user_id, old_category, new_category)
|
rename_listbooru(user_id, old_category, new_category)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.categories_for(user)
|
||||||
|
user.saved_searches.pluck("distinct category")
|
||||||
|
end
|
||||||
|
|
||||||
def normalize
|
def normalize
|
||||||
self.category = SavedSearch.normalize_category(category) if category
|
self.category = SavedSearch.normalize_category(category) if category
|
||||||
self.tag_query = SavedSearch.normalize(tag_query)
|
self.tag_query = SavedSearch.normalize(tag_query)
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ module PostSetPresenters
|
|||||||
related_tags_for_single(post_set.unordered_tag_array.first)
|
related_tags_for_single(post_set.unordered_tag_array.first)
|
||||||
elsif post_set.tag_string =~ /(?:^|\s)(?:#{Tag::SUBQUERY_METATAGS}):\S+/
|
elsif post_set.tag_string =~ /(?:^|\s)(?:#{Tag::SUBQUERY_METATAGS}):\S+/
|
||||||
calculate_related_tags_from_post_set
|
calculate_related_tags_from_post_set
|
||||||
|
elsif post_set.tag_string =~ /search:/
|
||||||
|
saved_search_tags
|
||||||
elsif post_set.is_empty_tag?
|
elsif post_set.is_empty_tag?
|
||||||
popular_tags
|
popular_tags
|
||||||
else
|
else
|
||||||
@@ -52,6 +54,10 @@ module PostSetPresenters
|
|||||||
RelatedTagCalculator.calculate_from_post_set_to_array(post_set).map(&:first)
|
RelatedTagCalculator.calculate_from_post_set_to_array(post_set).map(&:first)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def saved_search_tags
|
||||||
|
SavedSearch.categories_for(CurrentUser.user).map {|x| "search:#{x}"}
|
||||||
|
end
|
||||||
|
|
||||||
def tag_list_html(template, options = {})
|
def tag_list_html(template, options = {})
|
||||||
tag_set_presenter.tag_list_html(template, options)
|
tag_set_presenter.tag_list_html(template, options)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -111,9 +111,7 @@
|
|||||||
<th>Appeals</th>
|
<th>Appeals</th>
|
||||||
<td><%= presenter.appeal_count(self) %></td>
|
<td><%= presenter.appeal_count(self) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if CurrentUser.user.id == user.id || CurrentUser.is_moderator? %>
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Flags</th>
|
<th>Flags</th>
|
||||||
<td><%= presenter.flag_count(self) %></td>
|
<td><%= presenter.flag_count(self) %></td>
|
||||||
@@ -145,7 +143,18 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if CurrentUser.user.id == user.id %>
|
<% if CurrentUser.id == user.id %>
|
||||||
|
<% if CurrentUser.has_saved_searches? %>
|
||||||
|
<tr>
|
||||||
|
<th>Saved Searches</th>
|
||||||
|
<td>
|
||||||
|
<% SavedSearch.categories_for(CurrentUser.user).each do |category| %>
|
||||||
|
<p><%= link_to category, posts_path(tags: "search:#{category}") %></p>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>API Key</th>
|
<th>API Key</th>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user