Skip to content
Snippets Groups Projects
Commit 6704a40a authored by ArtOfCode-'s avatar ArtOfCode-
Browse files

Small efficiency improvements

parent a49da6af
Branches
Tags
No related merge requests found
......@@ -90,7 +90,7 @@ class CategoriesController < ApplicationController
SiteSetting['LotteryAgeDeprecationSpeed']] }
sort_param = sort_params[params[:sort]&.to_sym] || { last_activity: :desc }
@posts = @category.posts.undeleted.where(post_type_id: @category.display_post_types)
.includes(:post_type).list_includes.paginate(page: params[:page], per_page: 50)
.includes(:post_type, :tags).list_includes.paginate(page: params[:page], per_page: 50)
.order(sort_param)
end
......
......@@ -27,8 +27,8 @@
<div class="has-padding-top-2">
<% if is_question %>
<% tag_set = post.tag_set %>
<% required_ids = post.category&.required_tag_ids %>
<% topic_ids = post.category&.topic_tag_ids %>
<% required_ids = defined?(@category) ? @category&.required_tag_ids : post.category&.required_tag_ids %>
<% topic_ids = defined?(@category) ? @category&.topic_tag_ids : post.category&.topic_tag_ids %>
<% post.tags.category_sort_by(required_ids, topic_ids).each do |tag| %>
<% required = required_ids&.include? tag.id %>
<% topic = topic_ids&.include? tag.id %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment