Apply Style/CollectionMethods rubocop rule
We were already using `map` and `reduce` almost everywhere.
This commit is contained in:
@@ -80,9 +80,9 @@ class Admin::StatsController < Admin::BaseController
|
||||
|
||||
@vote_count = @budget.lines.count
|
||||
|
||||
@vote_count_by_heading = @budget.lines.group(:heading_id).count.collect { |k, v| [Budget::Heading.find(k).name, v] }.sort
|
||||
@vote_count_by_heading = @budget.lines.group(:heading_id).count.map { |k, v| [Budget::Heading.find(k).name, v] }.sort
|
||||
|
||||
@user_count_by_district = User.where.not(balloted_heading_id: nil).group(:balloted_heading_id).count.collect { |k, v| [Budget::Heading.find(k).name, v] }.sort
|
||||
@user_count_by_district = User.where.not(balloted_heading_id: nil).group(:balloted_heading_id).count.map { |k, v| [Budget::Heading.find(k).name, v] }.sort
|
||||
end
|
||||
|
||||
def polls
|
||||
|
||||
@@ -15,7 +15,7 @@ module Dashboard::GroupSupports
|
||||
|
||||
def accumulate_supports(grouped_votes)
|
||||
grouped_votes.each do |group, votes|
|
||||
grouped_votes[group] = votes.inject(0) { |sum, vote| sum + vote.vote_weight }
|
||||
grouped_votes[group] = votes.reduce(0) { |sum, vote| sum + vote.vote_weight }
|
||||
end
|
||||
|
||||
accumulated = 0
|
||||
|
||||
@@ -20,7 +20,7 @@ module RemotelyTranslatable
|
||||
end
|
||||
|
||||
def resources_groups(*args)
|
||||
feeds = args.detect { |arg| arg&.first.class == Widget::Feed } || []
|
||||
feeds = args.find { |arg| arg&.first.class == Widget::Feed } || []
|
||||
|
||||
args.compact - [feeds] + feeds.map(&:items)
|
||||
end
|
||||
|
||||
@@ -58,7 +58,7 @@ class Tracking::BudgetInvestmentsController < Tracking::BaseController
|
||||
}
|
||||
]
|
||||
|
||||
investment_headings.inject(all_headings_filter) do |filters, heading|
|
||||
investment_headings.reduce(all_headings_filter) do |filters, heading|
|
||||
filters << {
|
||||
name: heading.name,
|
||||
id: heading.id,
|
||||
|
||||
@@ -83,7 +83,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
}
|
||||
]
|
||||
|
||||
investment_headings.inject(all_headings_filter) do |filters, heading|
|
||||
investment_headings.reduce(all_headings_filter) do |filters, heading|
|
||||
filters << {
|
||||
name: heading.name,
|
||||
id: heading.id,
|
||||
|
||||
Reference in New Issue
Block a user