diff --git a/app/controllers/bubbles_controller.rb b/app/controllers/bubbles_controller.rb index 17610fc43..4e86e5b8d 100644 --- a/app/controllers/bubbles_controller.rb +++ b/app/controllers/bubbles_controller.rb @@ -5,8 +5,10 @@ class BubblesController < ApplicationController if params[:tag_id] @tag = Tag.find(params[:tag_id]) @bubbles = @tag.bubbles + @most_active_bubbles = @tag.bubbles.left_joins(:comments, :boosts).group(:id).order(Arel.sql('COUNT(comments.id) + COUNT(boosts.id) DESC')).limit(10) else - @bubbles = Bubble.all + @bubbles = Bubble.all.order(created_at: :desc) + @most_active_bubbles = Bubble.left_joins(:comments, :boosts).group(:id).order(Arel.sql('COUNT(comments.id) + COUNT(boosts.id) DESC')).limit(10) end end diff --git a/app/views/bubbles/index.html.erb b/app/views/bubbles/index.html.erb index c9c014ba0..55dd6765a 100644 --- a/app/views/bubbles/index.html.erb +++ b/app/views/bubbles/index.html.erb @@ -26,7 +26,9 @@ <% end %>
- <%= render @bubbles.last(10) %> + <% cache([@most_active_bubbles, 'stable_shuffle']) do %> + <%= render @most_active_bubbles.sort_by { |bubble| Digest::MD5.hexdigest("#{bubble.id}#{@most_active_bubbles.cache_key}") } %> + <% end %>
diff --git a/config/environments/development.rb b/config/environments/development.rb index e77b138fe..5c2cecd3d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -28,7 +28,7 @@ Rails.application.configure do "Cache-Control" => "public, max-age=#{2.days.to_i}" } else - config.action_controller.perform_caching = false + config.action_controller.perform_caching = true config.cache_store = :null_store end