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:
|
Rails/SkipsModelValidations:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Rails/UniqBeforePluck:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
RSpec/AlignLeftLetBrace:
|
RSpec/AlignLeftLetBrace:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ module ModerateActions
|
|||||||
@resources.accessible_by(current_ability, :ignore_flag).each(&:ignore_flag)
|
@resources.accessible_by(current_ability, :ignore_flag).each(&:ignore_flag)
|
||||||
|
|
||||||
elsif params[:block_authors].present?
|
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 }
|
User.where(id: author_ids).accessible_by(current_ability, :block).each { |user| block_user user }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class Tracking::BudgetInvestmentsController < Tracking::BaseController
|
|||||||
|
|
||||||
def heading_filters
|
def heading_filters
|
||||||
investments = @budget.investments.by_tracker(current_user.tracker&.id).distinct
|
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)
|
.order(name: :asc)
|
||||||
all_headings_filter = [
|
all_headings_filter = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,29 +18,29 @@ class UserSegments
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.all_proposal_authors
|
def self.all_proposal_authors
|
||||||
author_ids(Proposal.pluck(:author_id).uniq)
|
author_ids(Proposal.pluck(:author_id))
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.proposal_authors
|
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
|
end
|
||||||
|
|
||||||
def self.investment_authors
|
def self.investment_authors
|
||||||
author_ids(current_budget_investments.pluck(:author_id).uniq)
|
author_ids(current_budget_investments.pluck(:author_id))
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.feasible_and_undecided_investment_authors
|
def self.feasible_and_undecided_investment_authors
|
||||||
unfeasible_and_finished_condition = "feasibility = 'unfeasible' and valuation_finished = true"
|
unfeasible_and_finished_condition = "feasibility = 'unfeasible' and valuation_finished = true"
|
||||||
investments = current_budget_investments.where.not(unfeasible_and_finished_condition)
|
investments = current_budget_investments.where.not(unfeasible_and_finished_condition)
|
||||||
author_ids(investments.pluck(:author_id).uniq)
|
author_ids(investments.pluck(:author_id))
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.selected_investment_authors
|
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
|
end
|
||||||
|
|
||||||
def self.winner_investment_authors
|
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
|
end
|
||||||
|
|
||||||
def self.not_supported_on_current_budget
|
def self.not_supported_on_current_budget
|
||||||
|
|||||||
Reference in New Issue
Block a user