change intro explorer to use popular searches
This commit is contained in:
@@ -7,8 +7,8 @@ class PopularSearchService
|
|||||||
@scale = scale
|
@scale = scale
|
||||||
end
|
end
|
||||||
|
|
||||||
def each_search(&block)
|
def each_search(&block, limit = 100)
|
||||||
fetch_data.scan(/(.+?) (\d+)\.0\n/).each(&block)
|
fetch_data.scan(/(.+?) (\d+)\.0\n/).slice(0, limit).each(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_data
|
def fetch_data
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
class IntroPresenter
|
class IntroPresenter
|
||||||
def popular_tags
|
|
||||||
Tag.where("category = 3").order("post_count desc").limit(8).map(&:name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def each
|
def each
|
||||||
popular_tags.each do |tag|
|
PopularSearchService.new(Date.today, "week").each_search(20) do |query, count|
|
||||||
yield(tag, PostSets::Intro.new(tag))
|
yield(query, PostSets::Intro.new(query))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<p style="text-align: center;">Type in your favorite anime, manga, or character (last name first). Here are some examples:</p>
|
<p style="text-align: center;">Type in your favorite anime, manga, or character (last name first). Here are some popular examples:</p>
|
||||||
|
|
||||||
<% cache("intro-page", :expires_in => 1.hour) do %>
|
<% cache("intro-page", :expires_in => 1.hour) do %>
|
||||||
<% @presenter.each do |tag, post_set| %>
|
<% @presenter.each do |tag, post_set| %>
|
||||||
|
|||||||
Reference in New Issue
Block a user