mirror of
https://github.com/redmine/redmine.git
synced 2025-11-01 10:56:17 +01:00
Replace pluck().first with pick() (#32909).
Patch by Pavel Rosický and Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@20907 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -599,7 +599,7 @@ class IssueQuery < Query
|
|||||||
"1=0"
|
"1=0"
|
||||||
end
|
end
|
||||||
when "~"
|
when "~"
|
||||||
root_id, lft, rgt = Issue.where(:id => value.first.to_i).pluck(:root_id, :lft, :rgt).first
|
root_id, lft, rgt = Issue.where(:id => value.first.to_i).pick(:root_id, :lft, :rgt)
|
||||||
if root_id && lft && rgt
|
if root_id && lft && rgt
|
||||||
"#{Issue.table_name}.root_id = #{root_id} AND #{Issue.table_name}.lft > #{lft} AND #{Issue.table_name}.rgt < #{rgt}"
|
"#{Issue.table_name}.root_id = #{root_id} AND #{Issue.table_name}.lft > #{lft} AND #{Issue.table_name}.rgt < #{rgt}"
|
||||||
else
|
else
|
||||||
@@ -624,7 +624,7 @@ class IssueQuery < Query
|
|||||||
"1=0"
|
"1=0"
|
||||||
end
|
end
|
||||||
when "~"
|
when "~"
|
||||||
root_id, lft, rgt = Issue.where(:id => value.first.to_i).pluck(:root_id, :lft, :rgt).first
|
root_id, lft, rgt = Issue.where(:id => value.first.to_i).pick(:root_id, :lft, :rgt)
|
||||||
if root_id && lft && rgt
|
if root_id && lft && rgt
|
||||||
"#{Issue.table_name}.root_id = #{root_id} AND #{Issue.table_name}.lft < #{lft} AND #{Issue.table_name}.rgt > #{rgt}"
|
"#{Issue.table_name}.root_id = #{root_id} AND #{Issue.table_name}.lft < #{lft} AND #{Issue.table_name}.rgt > #{rgt}"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -665,7 +665,7 @@ class User < Principal
|
|||||||
return @project_ids_by_role if @project_ids_by_role
|
return @project_ids_by_role if @project_ids_by_role
|
||||||
|
|
||||||
group_class = anonymous? ? GroupAnonymous.unscoped : GroupNonMember.unscoped
|
group_class = anonymous? ? GroupAnonymous.unscoped : GroupNonMember.unscoped
|
||||||
group_id = group_class.pluck(:id).first
|
group_id = group_class.pick(:id)
|
||||||
|
|
||||||
members = Member.joins(:project, :member_roles).
|
members = Member.joins(:project, :member_roles).
|
||||||
where("#{Project.table_name}.status <> 9").
|
where("#{Project.table_name}.status <> 9").
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ class SupportForMultipleCommitKeywords < ActiveRecord::Migration[4.2]
|
|||||||
def up
|
def up
|
||||||
# Replaces commit_fix_keywords, commit_fix_status_id, commit_fix_done_ratio settings
|
# Replaces commit_fix_keywords, commit_fix_status_id, commit_fix_done_ratio settings
|
||||||
# with commit_update_keywords setting
|
# with commit_update_keywords setting
|
||||||
keywords = Setting.where(:name => 'commit_fix_keywords').limit(1).pluck(:value).first
|
keywords = Setting.where(:name => 'commit_fix_keywords').pick(:value)
|
||||||
status_id = Setting.where(:name => 'commit_fix_status_id').limit(1).pluck(:value).first
|
status_id = Setting.where(:name => 'commit_fix_status_id').pick(:value)
|
||||||
done_ratio = Setting.where(:name => 'commit_fix_done_ratio').limit(1).pluck(:value).first
|
done_ratio = Setting.where(:name => 'commit_fix_done_ratio').pick(:value)
|
||||||
if keywords.present?
|
if keywords.present?
|
||||||
Setting.commit_update_keywords = [{'keywords' => keywords, 'status_id' => status_id, 'done_ratio' => done_ratio}]
|
Setting.commit_update_keywords = [{'keywords' => keywords, 'status_id' => status_id, 'done_ratio' => done_ratio}]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ class AddTrackersDefaultStatusId < ActiveRecord::Migration[4.2]
|
|||||||
def up
|
def up
|
||||||
add_column :trackers, :default_status_id, :integer
|
add_column :trackers, :default_status_id, :integer
|
||||||
|
|
||||||
status_id = IssueStatus.where(:is_default => true).pluck(:id).first
|
status_id = IssueStatus.where(:is_default => true).pick(:id)
|
||||||
status_id ||= IssueStatus.order(:position).pluck(:id).first
|
status_id ||= IssueStatus.order(:position).pick(:id)
|
||||||
if status_id
|
if status_id
|
||||||
Tracker.update_all :default_status_id => status_id
|
Tracker.update_all :default_status_id => status_id
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class RemoveIssueStatusesIsDefault < ActiveRecord::Migration[4.2]
|
|||||||
def down
|
def down
|
||||||
add_column :issue_statuses, :is_default, :boolean, :null => false, :default => false
|
add_column :issue_statuses, :is_default, :boolean, :null => false, :default => false
|
||||||
# Restores the first status as default
|
# Restores the first status as default
|
||||||
default_status_id = IssueStatus.order(:position).pluck(:id).first
|
default_status_id = IssueStatus.order(:position).pick(:id)
|
||||||
IssueStatus.where(:id => default_status_id).update_all(:is_default => true)
|
IssueStatus.where(:id => default_status_id).update_all(:is_default => true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ module Redmine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def reload_nested_set_values
|
def reload_nested_set_values
|
||||||
self.root_id, self.lft, self.rgt = self.class.where(:id => id).pluck(:root_id, :lft, :rgt).first
|
self.root_id, self.lft, self.rgt = self.class.where(:id => id).pick(:root_id, :lft, :rgt)
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_nested_set_values
|
def save_nested_set_values
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ module Redmine
|
|||||||
if siblings_rgt
|
if siblings_rgt
|
||||||
siblings_rgt + 1
|
siblings_rgt + 1
|
||||||
elsif parent_id
|
elsif parent_id
|
||||||
parent_lft = self.class.where(:id => parent_id).pluck(:lft).first
|
parent_lft = self.class.where(:id => parent_id).pick(:lft)
|
||||||
unless parent_lft
|
unless parent_lft
|
||||||
raise "Project id=#{id} with parent_id=#{parent_id}: parent missing or without 'lft' value"
|
raise "Project id=#{id} with parent_id=#{parent_id}: parent missing or without 'lft' value"
|
||||||
end
|
end
|
||||||
@@ -136,7 +136,7 @@ module Redmine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def reload_nested_set_values
|
def reload_nested_set_values
|
||||||
self.lft, self.rgt = Project.where(:id => id).pluck(:lft, :rgt).first
|
self.lft, self.rgt = Project.where(:id => id).pick(:lft, :rgt)
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_nested_set_values
|
def save_nested_set_values
|
||||||
|
|||||||
Reference in New Issue
Block a user