Performance: save some queries when pluck is not needed (#3160)
This commit is contained in:
parent
74ecf5ca06
commit
c42c28ae59
4 changed files with 5 additions and 5 deletions
|
|
@ -9,7 +9,7 @@ class Internal::FeedbackMessagesController < Internal::ApplicationController
|
|||
includes(:reporter, :notes).
|
||||
order("feedback_messages.created_at DESC").
|
||||
page(params[:page] || 1).per(5)
|
||||
@email_messages = EmailMessage.find_for_reports(@feedback_messages.pluck(:id))
|
||||
@email_messages = EmailMessage.find_for_reports(@feedback_messages)
|
||||
@vomits = get_vomits
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ModerationsController < ApplicationController
|
|||
order("hotness_score DESC").limit(100)
|
||||
@articles = @articles.cached_tagged_with(params[:tag]) if params[:tag].present?
|
||||
|
||||
@rating_votes = RatingVote.where(article: @articles.pluck(:id), user: current_user)
|
||||
@rating_votes = RatingVote.where(article: @articles, user: current_user)
|
||||
@articles = @articles.decorate
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class PagesController < ApplicationController
|
|||
@articles = Article.published.tagged_with(%w[shecoded shecodedally theycoded], any: true).
|
||||
where(approved: true).where("published_at > ? AND score > ?", 3.weeks.ago, -8).
|
||||
order(Arel.sql("RANDOM()")).
|
||||
where.not(id: @top_articles.pluck(:id)).
|
||||
where.not(id: @top_articles).
|
||||
includes(:user).decorate
|
||||
render layout: false
|
||||
set_surrogate_key_header "shecoded_page"
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ module Mentions
|
|||
private
|
||||
|
||||
def delete_removed_mentions(usernames)
|
||||
user_ids = User.where(username: usernames).pluck(:id)
|
||||
mentions = @notifiable.mentions.where.not(user_id: user_ids).destroy_all
|
||||
users = User.where(username: usernames)
|
||||
mentions = @notifiable.mentions.where.not(user_id: users).destroy_all
|
||||
Notification.remove_each(mentions) if mentions.present?
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue