From 4021ddb5791909b9a810f34450c8264203496d61 Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 9 Dec 2021 22:53:22 -0600 Subject: [PATCH] Fix N+1 queries problem in /explore/posts/popular.json. --- app/controllers/explore/posts_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/explore/posts_controller.rb b/app/controllers/explore/posts_controller.rb index 20e289356..7d12924ea 100644 --- a/app/controllers/explore/posts_controller.rb +++ b/app/controllers/explore/posts_controller.rb @@ -51,11 +51,11 @@ module Explore end def popular_posts(min_date, max_date) - Post.where(created_at: min_date..max_date).user_tag_match("order:score") + Post.where(created_at: min_date..max_date).includes(:media_asset).user_tag_match("order:score") end def curated_posts(min_date, max_date) - Post.where(created_at: min_date..max_date).user_tag_match("order:curated") + Post.where(created_at: min_date..max_date).includes(:media_asset).user_tag_match("order:curated") end end end