eliminate month scale for popular searches (takes up too much space in redis)

This commit is contained in:
r888888888
2017-11-10 15:40:10 -08:00
parent 354247e3c7
commit 8458c62e8a
5 changed files with 8 additions and 16 deletions

View File

@@ -10,7 +10,7 @@ module Explore
def searches
@date = params[:date] ? Date.parse(params[:date]) : Date.today
@search_service = PopularSearchService.new(@date, params[:scale] || "day")
@search_service = PopularSearchService.new(@date)
end
def missed_searches

View File

@@ -1,18 +1,18 @@
# queries reportbooru to find popular post searches
class PopularSearchService
attr_reader :date, :scale
attr_reader :date
def self.enabled?
Danbooru.config.reportbooru_server.present?
end
def initialize(date, scale)
def initialize(date)
if !PopularSearchService.enabled?
raise NotImplementedError.new("the Reportbooru service isn't configured. Popular searches are not available.")
end
@date = date
@scale = scale
@scale = "day"
end
def each_search(limit = 100, &block)

View File

@@ -1,6 +1,6 @@
class IntroPresenter
def each
PopularSearchService.new(Date.today, "month").each_search(20) do |query, count|
PopularSearchService.new(Date.today).each_search(20) do |query, count|
yield(query, PostSets::Intro.new(query))
end
end

View File

@@ -33,7 +33,7 @@ module PostSetPresenters
def popular_tags
if PopularSearchService.enabled?
PopularSearchService.new(Date.today, "day").tags.slice(0, 25)
PopularSearchService.new(Date.today).tags.slice(0, 25)
else
Tag.trending
end

View File

@@ -20,17 +20,9 @@
</table>
<p style="margin-top: 2em;">
View by
<%= link_to "day", searches_explore_posts_path(:date => params[:date], :scale => "day") %> |
<%= link_to "month", searches_explore_posts_path(:date => params[:date], :scale => "month") %>.
<%= link_to "< Previous", searches_explore_posts_path(:date => 1.day.ago(@date)) %>
Back one
<%= link_to "day", searches_explore_posts_path(:date => 1.day.ago(@date), :scale => params[:scale]) %> |
<%= link_to "month", searches_explore_posts_path(:date => 1.month.ago(@date), :scale => params[:scale]) %>.
Forward one
<%= link_to "day", searches_explore_posts_path(:date => 1.day.since(@date), :scale => params[:scale]) %> |
<%= link_to "month", searches_explore_posts_path(:date => 1.month.since(@date), :scale => params[:scale]) %>.
<%= link_to "Next >", searches_explore_posts_path(:date => 1.day.since(@date)) %>
</p>
</div>
</div>