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