diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 565726687..43ca6f7f3 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,7 +1,7 @@ module Admin class UsersController < Admin::ApplicationController def index - scope = User.all + scope = User.all.includes(:profile) scope = scope.where(type: params[:type]) if params[:type].present? scope = scope.where(state: params[:state]) if params[:state].present? field = params[:field] || "login" diff --git a/app/controllers/topics/list_actions.rb b/app/controllers/topics/list_actions.rb index de666f843..fd4b08951 100644 --- a/app/controllers/topics/list_actions.rb +++ b/app/controllers/topics/list_actions.rb @@ -62,7 +62,7 @@ def topics_scope(base_scope = Topic, without_nodes: true) end # must include :user, because it's uses for _topic.html.erb fragment cache_key - scope.includes(:user) + scope.includes(:user, :node, :last_reply_user) end end end diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 86f14addb..2ed26c8e7 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -10,9 +10,9 @@ class TopicsController < ApplicationController def index @suggest_topics = [] if params[:page].to_i <= 1 - @suggest_topics = topics_scope.suggest.includes(:node).limit(3) + @suggest_topics = topics_scope.suggest.limit(3) end - @topics = topics_scope.without_suggest.last_actived.includes(:node).page(params[:page]) + @topics = topics_scope.without_suggest.last_actived.page(params[:page]) @page_title = t("menu.topics") @read_topic_ids = [] if current_user @@ -21,7 +21,7 @@ def index end def feed - @topics = Topic.recent.without_ban.without_hide_nodes.includes(:node, :user, :last_reply_user).limit(20) + @topics = Topic.recent.without_ban.without_hide_nodes.limit(20) render layout: false if stale?(@topics) end @@ -35,19 +35,19 @@ def node def node_feed @node = Node.find(params[:id]) - @topics = @node.topics.recent.limit(20) + @topics = @node.topics.includes(:user, :node, :last_reply_user).recent.limit(20) render layout: false end def show - @topic = Topic.unscoped.includes(:user).find(params[:id]) + @topic = Topic.unscoped.includes(:user, :last_reply_user).find(params[:id]) render_404 if @topic.deleted? @node = @topic.node @show_raw = params[:raw] == "1" @can_reply = can?(:create, Reply) - @replies = Reply.unscoped.where(topic_id: @topic.id).order(:id).all + @replies = Reply.unscoped.where(topic_id: @topic.id).includes(:user).order(:id).all @user_like_reply_ids = current_user&.like_reply_ids_by_replies(@replies) || [] @has_followed = current_user&.follow_topic?(@topic) diff --git a/app/controllers/users/user_actions.rb b/app/controllers/users/user_actions.rb index d7a4c281e..9bc6c38f9 100644 --- a/app/controllers/users/user_actions.rb +++ b/app/controllers/users/user_actions.rb @@ -74,7 +74,7 @@ def only_user! def user_show @replies = @user.replies.without_system.fields_for_list.recent.includes(:topic).limit(10) - @topics = @user.topics.fields_for_list.high_likes.page(params[:page]) + @topics = @user.topics.fields_for_list.high_likes.includes(:node).page(params[:page]) end end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 279e01edb..d87ab4067 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -23,7 +23,7 @@ def index end def feed - @topics = @user.topics.recent.limit(20) + @topics = @user.topics.includes(:node).recent.limit(20) end def city