Use pluck(:id) instead of collect(&:id) (#26711).

Patch by jwjw yy.


git-svn-id: http://svn.redmine.org/redmine/trunk@17454 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2018-07-28 15:24:24 +00:00
parent 399a66a9a9
commit 1c5600f820
2 changed files with 2 additions and 2 deletions

View File

@@ -34,7 +34,7 @@ class VersionsController < ApplicationController
@trackers = @project.trackers.sorted.to_a
retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?})
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
project_ids = @with_subprojects ? @project.self_and_descendants.pluck(:id) : [@project.id]
@versions = @project.shared_versions.preload(:custom_values)
@versions += @project.rolled_up_versions.visible.preload(:custom_values) if @with_subprojects

View File

@@ -1383,7 +1383,7 @@ class Issue < ActiveRecord::Base
# Unassigns issues from versions that are no longer shared
# after +project+ was moved
def self.update_versions_from_hierarchy_change(project)
moved_project_ids = project.self_and_descendants.reload.collect(&:id)
moved_project_ids = project.self_and_descendants.reload.pluck(:id)
# Update issues of the moved projects and issues assigned to a version of a moved project
Issue.update_versions(
["#{Version.table_name}.project_id IN (?) OR #{Issue.table_name}.project_id IN (?)",