Add and apply Rails/PluckId rubocop rule
This commit is contained in:
@@ -24,7 +24,7 @@ class Admin::StatsController < Admin::BaseController
|
||||
.count(:voter_id)
|
||||
|
||||
@user_ids_who_didnt_vote_proposals = @verified_users - @user_ids_who_voted_proposals
|
||||
budgets_ids = Budget.where.not(phase: "finished").pluck(:id)
|
||||
budgets_ids = Budget.where.not(phase: "finished").ids
|
||||
@budgets = budgets_ids.size
|
||||
@investments = Budget::Investment.where(budget_id: budgets_ids).count
|
||||
end
|
||||
|
||||
@@ -44,7 +44,7 @@ module Budgets
|
||||
def index
|
||||
@investments = investments.page(params[:page]).per(PER_PAGE).for_render
|
||||
|
||||
@investment_ids = @investments.pluck(:id)
|
||||
@investment_ids = @investments.ids
|
||||
@investments_map_coordinates = MapLocation.where(investment: investments).map(&:json_data)
|
||||
|
||||
@tag_cloud = tag_cloud
|
||||
|
||||
@@ -117,7 +117,7 @@ module ProposalsDashboardHelper
|
||||
|
||||
def new_resources_since_last_login?(resources, new_actions_since_last_login)
|
||||
if resources.present?
|
||||
resources.pluck(:id).any? { |id| new_actions_since_last_login.include?(id) }
|
||||
resources.ids.any? { |id| new_actions_since_last_login.include?(id) }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -164,10 +164,10 @@ class Budget
|
||||
results = results.winners if params[:advanced_filters].include?("winners")
|
||||
|
||||
ids = []
|
||||
ids += results.valuation_finished_feasible.pluck(:id) if params[:advanced_filters].include?("feasible")
|
||||
ids += results.where(selected: true).pluck(:id) if params[:advanced_filters].include?("selected")
|
||||
ids += results.undecided.pluck(:id) if params[:advanced_filters].include?("undecided")
|
||||
ids += results.unfeasible.pluck(:id) if params[:advanced_filters].include?("unfeasible")
|
||||
ids += results.valuation_finished_feasible.ids if params[:advanced_filters].include?("feasible")
|
||||
ids += results.where(selected: true).ids if params[:advanced_filters].include?("selected")
|
||||
ids += results.undecided.ids if params[:advanced_filters].include?("undecided")
|
||||
ids += results.unfeasible.ids if params[:advanced_filters].include?("unfeasible")
|
||||
results = results.where(id: ids) if ids.any?
|
||||
results
|
||||
end
|
||||
@@ -191,8 +191,8 @@ class Budget
|
||||
return results if max_per_heading <= 0
|
||||
|
||||
ids = []
|
||||
budget.headings.pluck(:id).each do |hid|
|
||||
ids += Investment.where(heading_id: hid).order(confidence_score: :desc).limit(max_per_heading).pluck(:id)
|
||||
budget.headings.ids.each do |hid|
|
||||
ids += Investment.where(heading_id: hid).order(confidence_score: :desc).limit(max_per_heading).ids
|
||||
end
|
||||
|
||||
results.where(id: ids)
|
||||
|
||||
@@ -3,7 +3,7 @@ module Randomizable
|
||||
|
||||
class_methods do
|
||||
def sort_by_random(seed = rand(10_000_000))
|
||||
ids = order(:id).pluck(:id).shuffle(random: Random.new(seed))
|
||||
ids = order(:id).ids.shuffle(random: Random.new(seed))
|
||||
|
||||
return all if ids.empty?
|
||||
|
||||
|
||||
@@ -86,10 +86,7 @@ class Dashboard::Action < ApplicationRecord
|
||||
actions_for_today = get_actions_for_today(proposal)
|
||||
actions_for_date = get_actions_for_date(proposal, date)
|
||||
|
||||
actions_for_today_ids = actions_for_today.pluck(:id)
|
||||
actions_for_date_ids = actions_for_date.pluck(:id)
|
||||
|
||||
actions_for_today_ids - actions_for_date_ids
|
||||
actions_for_today.ids - actions_for_date.ids
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -22,11 +22,11 @@ class Legislation::Question < ApplicationRecord
|
||||
scope :sorted, -> { order("id ASC") }
|
||||
|
||||
def next_question_id
|
||||
@next_question_id ||= process.questions.where("id > ?", id).sorted.limit(1).pluck(:id).first
|
||||
@next_question_id ||= process.questions.where("id > ?", id).sorted.limit(1).ids.first
|
||||
end
|
||||
|
||||
def first_question_id
|
||||
@first_question_id ||= process.questions.sorted.limit(1).pluck(:id).first
|
||||
@first_question_id ||= process.questions.sorted.limit(1).ids.first
|
||||
end
|
||||
|
||||
def answer_for_user(user)
|
||||
|
||||
@@ -114,7 +114,7 @@ class Proposal < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.not_followed_by_user(user)
|
||||
where.not(id: followed_by_user(user).pluck(:id))
|
||||
where.not(id: followed_by_user(user).ids)
|
||||
end
|
||||
|
||||
def to_param
|
||||
|
||||
@@ -243,7 +243,7 @@ class User < ApplicationRecord
|
||||
Comment.hide_all comment_ids
|
||||
Proposal.hide_all proposal_ids
|
||||
Budget::Investment.hide_all budget_investment_ids
|
||||
ProposalNotification.hide_all ProposalNotification.where(author_id: id).pluck(:id)
|
||||
ProposalNotification.hide_all ProposalNotification.where(author_id: id).ids
|
||||
end
|
||||
|
||||
def full_restore
|
||||
|
||||
Reference in New Issue
Block a user