"1=0"
end
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
"#{Issue.table_name}.root_id = #{root_id} AND #{Issue.table_name}.lft > #{lft} AND #{Issue.table_name}.rgt < #{rgt}"
else
"1=0"
end
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
"#{Issue.table_name}.root_id = #{root_id} AND #{Issue.table_name}.lft < #{lft} AND #{Issue.table_name}.rgt > #{rgt}"
else
return @project_ids_by_role if @project_ids_by_role
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).
where("#{Project.table_name}.status <> 9").
def up
# Replaces commit_fix_keywords, commit_fix_status_id, commit_fix_done_ratio settings
# with commit_update_keywords setting
- keywords = Setting.where(:name => 'commit_fix_keywords').limit(1).pluck(:value).first
- status_id = Setting.where(:name => 'commit_fix_status_id').limit(1).pluck(:value).first
- done_ratio = Setting.where(:name => 'commit_fix_done_ratio').limit(1).pluck(:value).first
+ keywords = Setting.where(:name => 'commit_fix_keywords').pick(:value)
+ status_id = Setting.where(:name => 'commit_fix_status_id').pick(:value)
+ done_ratio = Setting.where(:name => 'commit_fix_done_ratio').pick(:value)
if keywords.present?
Setting.commit_update_keywords = [{'keywords' => keywords, 'status_id' => status_id, 'done_ratio' => done_ratio}]
end
def up
add_column :trackers, :default_status_id, :integer
- status_id = IssueStatus.where(:is_default => true).pluck(:id).first
- status_id ||= IssueStatus.order(:position).pluck(:id).first
+ status_id = IssueStatus.where(:is_default => true).pick(:id)
+ status_id ||= IssueStatus.order(:position).pick(:id)
if status_id
Tracker.update_all :default_status_id => status_id
end
def down
add_column :issue_statuses, :is_default, :boolean, :null => false, :default => false
# 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)
end
end
end
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
def save_nested_set_values
if siblings_rgt
siblings_rgt + 1
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
raise "Project id=#{id} with parent_id=#{parent_id}: parent missing or without 'lft' value"
end
end
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
def save_nested_set_values