diff --git a/app/controllers/explore/posts_controller.rb b/app/controllers/explore/posts_controller.rb index eadbb4533..35a396ce2 100644 --- a/app/controllers/explore/posts_controller.rb +++ b/app/controllers/explore/posts_controller.rb @@ -1,6 +1,7 @@ module Explore class PostsController < ApplicationController respond_to :html, :xml, :json + before_filter :set_date, only: [:searches, :viewed] def popular @post_set = PostSets::Popular.new(params[:date], params[:scale]) @@ -9,13 +10,12 @@ module Explore end def viewed - @post_set = PostSets::MostViewed.new(params[:date]) + @post_set = PostSets::MostViewed.new(@date.to_s) @posts = @post_set.posts respond_with(@posts) end def searches - @date = params[:date] ? Date.parse(params[:date]) : Date.today @search_service = PopularSearchService.new(@date) end @@ -27,5 +27,10 @@ module Explore @presenter = IntroPresenter.new render :layout => "blank" end + + private + def set_date + @date = params[:date] ? Date.parse(params[:date]) : Date.today + end end end diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index 39e358433..64ce28c6c 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -1,4 +1,8 @@ module PostsHelper + def discover_mode? + params[:tags] =~ /order:rank/ || params[:action] =~ /searches|viewed/ + end + def next_page_url current_page = (params[:page] || 1).to_i dup_params = params.dup diff --git a/app/logical/post_view_count_service.rb b/app/logical/post_view_count_service.rb index b0d7436d8..95f23eecc 100644 --- a/app/logical/post_view_count_service.rb +++ b/app/logical/post_view_count_service.rb @@ -33,6 +33,6 @@ class PostViewCountService def popular_posts(date = Date.today) ranking = fetch_rank(date) || [] - ranking.map {|x| Post.find(x[0])} + ranking.slice(0, 50).map {|x| Post.find(x[0])} end end diff --git a/app/views/explore/posts/missed_searches.html.erb b/app/views/explore/posts/missed_searches.html.erb index b676aa125..3bedafae6 100644 --- a/app/views/explore/posts/missed_searches.html.erb +++ b/app/views/explore/posts/missed_searches.html.erb @@ -1,6 +1,7 @@
Over the past seven days.
- <%= link_to "< Previous", searches_explore_posts_path(:date => 1.day.ago(@date)) %> - - <%= link_to "Next >", searches_explore_posts_path(:date => 1.day.since(@date)) %> -
+