Actions
Patch #26714
closedpluck instead of map in issue_query
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Code cleanup/refactoring
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Description
The previous issue_query.rb, line 438 version_ids = versions(:conditions => [where]).map(&:id) will issue query as:
SELECT `versions`.`id` AS t0_r0, `versions`.`project_id` AS t0_r1, `versions`.`name` AS t0_r2, `versions`.`description` AS t0_r3, `versions`.`effective_date` AS t0_r4, `versions`.`created_on` AS t0_r5, `versions`.`updated_on` AS t0_r6, `versions`.`wiki_page_title` AS t0_r7, `versions`.`status` AS t0_r8, `versions`.`sharing` AS t0_r9, `projects`.`id` AS t1_r0, `projects`.`name` AS t1_r1, `projects`.`description` AS t1_r2, `projects`.`homepage` AS t1_r3, `projects`.`is_public` AS t1_r4, `projects`.`parent_id` AS t1_r5, `projects`.`created_on` AS t1_r6, `projects`.`updated_on` AS t1_r7, `projects`.`identifier` AS t1_r8, `projects`.`status` AS t1_r9, `projects`.`lft` AS t1_r10, `projects`.`rgt` AS t1_r11, `projects`.`inherit_members` AS t1_r12, `projects`.`default_version_id` AS t1_r13 FROM `versions` INNER JOIN `projects` ON `projects`.`id` = `versions`.`project_id` WHERE (projects.status <> 9 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='issue_tracking')) AND ( 1 = 1 )
However, only id is needed, so , it's possible to change to
version_ids = versions_for_id(:conditions => [where]).pluck(:id)
def versions_for_id(options={})
Version.visible.
where(project_statement).
where(options[:conditions]).
includes(:project).
references(:project)
rescue ::ActiveRecord::StatementInvalid => e
raise StatementInvalid.new(e.message)
end
As shown in diff.rb
Files
Updated by Toshi MARUYAMA over 7 years ago
- Tracker changed from Defect to Patch
- Category changed from Issues to Code cleanup/refactoring
Updated by Toshi MARUYAMA over 7 years ago
- Status changed from New to Needs feedback
I think your IssueQuery#versions_for_id is named IssueQuery#version_ids and pluck(:id) is in it for consistency.
source:tags/3.4.2/app/models/issue_query.rb#L310
Please add ".diff" in your patch file name and remove commented lines from your patch.
Updated by Toshi MARUYAMA over 7 years ago
- File issue_query.v3.diff issue_query.v3.diff added
- Status changed from Needs feedback to New
- Target version set to 4.1.0
pluck(:id) in IssueQuery#version_ids is missing.
Updated by jwjw yy over 6 years ago
- Status changed from New to Resolved
Removed advertisement -- Holger Just
Updated by Jean-Philippe Lang over 5 years ago
- Target version changed from 4.1.0 to 4.2.0
Need some work to avoid duplicate code with IssueQuery#versions
.
Updated by Go MAEDA over 3 years ago
- Target version changed from 4.2.0 to Candidate for next major release
Actions