Remove unnecessary uniq calls
The code `where(id: ids)` is equivalent to `where(id: ids.uniq)`. Since Rails 5 uses `distinct` instead of `uniq` and in most cases where we use `uniq` with `pluck` we should simply remove the `uniq` call (as done in this commit), we're also removing the `Rails/UniqBeforePluck` rubocop rule.
This commit is contained in:
@@ -93,9 +93,6 @@ Rails/SaveBang:
|
||||
Rails/SkipsModelValidations:
|
||||
Enabled: true
|
||||
|
||||
Rails/UniqBeforePluck:
|
||||
Enabled: true
|
||||
|
||||
RSpec/AlignLeftLetBrace:
|
||||
Enabled: false
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ module ModerateActions
|
||||
@resources.accessible_by(current_ability, :ignore_flag).each(&:ignore_flag)
|
||||
|
||||
elsif params[:block_authors].present?
|
||||
author_ids = @resources.pluck(author_id).uniq
|
||||
author_ids = @resources.pluck(author_id)
|
||||
User.where(id: author_ids).accessible_by(current_ability, :block).each { |user| block_user user }
|
||||
end
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class Tracking::BudgetInvestmentsController < Tracking::BaseController
|
||||
|
||||
def heading_filters
|
||||
investments = @budget.investments.by_tracker(current_user.tracker&.id).distinct
|
||||
investment_headings = Budget::Heading.where(id: investments.pluck(:heading_id).uniq)
|
||||
investment_headings = Budget::Heading.where(id: investments.pluck(:heading_id))
|
||||
.order(name: :asc)
|
||||
all_headings_filter = [
|
||||
{
|
||||
|
||||
@@ -18,29 +18,29 @@ class UserSegments
|
||||
end
|
||||
|
||||
def self.all_proposal_authors
|
||||
author_ids(Proposal.pluck(:author_id).uniq)
|
||||
author_ids(Proposal.pluck(:author_id))
|
||||
end
|
||||
|
||||
def self.proposal_authors
|
||||
author_ids(Proposal.not_archived.not_retired.pluck(:author_id).uniq)
|
||||
author_ids(Proposal.not_archived.not_retired.pluck(:author_id))
|
||||
end
|
||||
|
||||
def self.investment_authors
|
||||
author_ids(current_budget_investments.pluck(:author_id).uniq)
|
||||
author_ids(current_budget_investments.pluck(:author_id))
|
||||
end
|
||||
|
||||
def self.feasible_and_undecided_investment_authors
|
||||
unfeasible_and_finished_condition = "feasibility = 'unfeasible' and valuation_finished = true"
|
||||
investments = current_budget_investments.where.not(unfeasible_and_finished_condition)
|
||||
author_ids(investments.pluck(:author_id).uniq)
|
||||
author_ids(investments.pluck(:author_id))
|
||||
end
|
||||
|
||||
def self.selected_investment_authors
|
||||
author_ids(current_budget_investments.selected.pluck(:author_id).uniq)
|
||||
author_ids(current_budget_investments.selected.pluck(:author_id))
|
||||
end
|
||||
|
||||
def self.winner_investment_authors
|
||||
author_ids(current_budget_investments.winners.pluck(:author_id).uniq)
|
||||
author_ids(current_budget_investments.winners.pluck(:author_id))
|
||||
end
|
||||
|
||||
def self.not_supported_on_current_budget
|
||||
|
||||
Reference in New Issue
Block a user