https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292017-08-21T05:52:08ZRedmineRedmine - Patch #26726: Use pluck(:id) instead of collect(&:id) https://www.redmine.org/issues/26726?journal_id=807462017-08-21T05:52:08ZToshi MARUYAMA
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/80746/diff?detail_id=63661">diff</a>)</li><li><strong>Category</strong> set to <i>Code cleanup/refactoring</i></li><li><strong>Status</strong> changed from <i>New</i> to <i>Needs feedback</i></li></ul><p>Please post by patch.</p> Redmine - Patch #26726: Use pluck(:id) instead of collect(&:id) https://www.redmine.org/issues/26726?journal_id=807492017-08-21T05:58:44ZToshi MARUYAMA
<ul></ul><p>And please describe why this change is effective.</p> Redmine - Patch #26726: Use pluck(:id) instead of collect(&:id) https://www.redmine.org/issues/26726?journal_id=807722017-08-21T17:57:11Zjwjw yy
<ul></ul><p>Since pluck will only access the specific field but collect will retrieve every field of the object.</p> Redmine - Patch #26726: Use pluck(:id) instead of collect(&:id) https://www.redmine.org/issues/26726?journal_id=807932017-08-23T05:00:48ZToshi MARUYAMA
<ul></ul><p>Toshi MARUYAMA wrote:</p>
<blockquote>
<p>Please post by patch.</p>
</blockquote>
<p>Please post by attachment patch file.</p> Redmine - Patch #26726: Use pluck(:id) instead of collect(&:id) https://www.redmine.org/issues/26726?journal_id=863572018-07-28T08:43:00ZGo MAEDA
<ul><li><strong>Subject</strong> changed from <i>collect(&:id) could be pluck(:id)</i> to <i>Use pluck(:id) instead of collect(&:id) </i></li><li><strong>Status</strong> changed from <i>Needs feedback</i> to <i>New</i></li><li><strong>Target version</strong> set to <i>4.1.0</i></li></ul><pre><code class="diff syntaxhl"><span class="gh">Index: app/controllers/versions_controller.rb
===================================================================
</span><span class="gd">--- app/controllers/versions_controller.rb (revision 17452)
</span><span class="gi">+++ app/controllers/versions_controller.rb (working copy)
</span><span class="p">@@ -34,7 +34,7 @@</span>
@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')
<span class="gd">- project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
</span><span class="gi">+ project_ids = @with_subprojects ? @project.self_and_descendants.pluck(:id) : [@project.id]
</span>
@versions = @project.shared_versions.preload(:custom_values)
@versions += @project.rolled_up_versions.visible.preload(:custom_values) if @with_subprojects
<span class="gh">Index: app/models/issue.rb
===================================================================
</span><span class="gd">--- app/models/issue.rb (revision 17452)
</span><span class="gi">+++ app/models/issue.rb (working copy)
</span><span class="p">@@ -1383,7 +1383,7 @@</span>
# Unassigns issues from versions that are no longer shared
# after +project+ was moved
def self.update_versions_from_hierarchy_change(project)
<span class="gd">- moved_project_ids = project.self_and_descendants.reload.collect(&:id)
</span><span class="gi">+ moved_project_ids = project.self_and_descendants.reload.pluck(:id)
</span> # 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 (?)",
</code></pre> Redmine - Patch #26726: Use pluck(:id) instead of collect(&:id) https://www.redmine.org/issues/26726?journal_id=863602018-07-28T15:21:36ZGo MAEDA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-3 status-5 priority-4 priority-default closed" href="/issues/26711">Patch #26711</a>: Use pluck instead of collect/map</i> added</li></ul> Redmine - Patch #26726: Use pluck(:id) instead of collect(&:id) https://www.redmine.org/issues/26726?journal_id=863622018-07-28T15:26:49ZGo MAEDA
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Closed</i></li><li><strong>Target version</strong> deleted (<del><i>4.1.0</i></del>)</li></ul><p>Committed as <a class="changeset" title="Use pluck(:id) instead of collect(&:id) (#26711). Patch by jwjw yy." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17454">r17454</a>. Thank you.</p>