Skip to content

Commit

Permalink
Small efficiency improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtOfCode- committed Jun 1, 2020
1 parent a49da6a commit 6704a40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/categories_controller.rb
Expand Up @@ -90,7 +90,7 @@ def set_list_posts
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

Expand Down
4 changes: 2 additions & 2 deletions app/views/posts/_list.html.erb
Expand Up @@ -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 %>
Expand Down

0 comments on commit 6704a40

Please sign in to comment.