Skip to content

Commit

Permalink
Merge pull request #5 from homeland-plugins/fix-n+1-query
Browse files Browse the repository at this point in the history
Fix N+1 query, after we removed second_level_cache.
  • Loading branch information
huacnlee authored Oct 29, 2024
2 parents 205eaa4 + ef5a342 commit 8015e7f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/controllers/homeland/jobs/jobs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ class JobsController < ::ApplicationController
before_action :set_node

def index
@suggest_topics = Topic.where(node_id: @node.id).suggest.limit(3)
@suggest_topics = Topic.where(node_id: @node.id).includes(:user, :node, :last_reply_user).suggest.limit(3)
suggest_topic_ids = @suggest_topics.map(&:id)
@topics = Topic.where(node_id: @node.id)

# New ban filter by :grade column
@topics = @topics.without_ban if @topics.respond_to?(:without_ban)

@topics = @topics.where.not(id: suggest_topic_ids) if suggest_topic_ids.count > 0
@topics = @topics.last_actived.includes(:user).page(params[:page])
@topics = @topics.last_actived.includes(:user, :node, :last_reply_user).page(params[:page])
@topics = @topics.where("title ilike ?", "%[#{params[:location]}]%") if params[:location]
@page_title = '招聘'
end
Expand Down
4 changes: 2 additions & 2 deletions boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
s.name = 'jobs'
s.display_name = '招聘'
s.description = "简单的招聘栏目"
s.version = "1.0.0"
s.version = "1.1.0"
s.navbar_link = true
s.root_path = "/jobs"
end
end

0 comments on commit 8015e7f

Please sign in to comment.