Project

General

Profile

Patch #32909 » 0001-Replace-pluck-.first-with-pick.patch

Marius BĂLTEANU, 2021-04-02 22:50

View differences:

app/models/issue_query.rb
599 599
        "1=0"
600 600
      end
601 601
    when "~"
602
      root_id, lft, rgt = Issue.where(:id => value.first.to_i).pluck(:root_id, :lft, :rgt).first
602
      root_id, lft, rgt = Issue.where(:id => value.first.to_i).pick(:root_id, :lft, :rgt)
603 603
      if root_id && lft && rgt
604 604
        "#{Issue.table_name}.root_id = #{root_id} AND #{Issue.table_name}.lft > #{lft} AND #{Issue.table_name}.rgt < #{rgt}"
605 605
      else
......
624 624
        "1=0"
625 625
      end
626 626
    when "~"
627
      root_id, lft, rgt = Issue.where(:id => value.first.to_i).pluck(:root_id, :lft, :rgt).first
627
      root_id, lft, rgt = Issue.where(:id => value.first.to_i).pick(:root_id, :lft, :rgt)
628 628
      if root_id && lft && rgt
629 629
        "#{Issue.table_name}.root_id = #{root_id} AND #{Issue.table_name}.lft < #{lft} AND #{Issue.table_name}.rgt > #{rgt}"
630 630
      else
app/models/user.rb
665 665
      return @project_ids_by_role if @project_ids_by_role
666 666

  
667 667
      group_class = anonymous? ? GroupAnonymous.unscoped : GroupNonMember.unscoped
668
      group_id = group_class.pluck(:id).first
668
      group_id = group_class.pick(:id)
669 669

  
670 670
      members = Member.joins(:project, :member_roles).
671 671
        where("#{Project.table_name}.status <> 9").
db/migrate/20131004113137_support_for_multiple_commit_keywords.rb
2 2
  def up
3 3
    # Replaces commit_fix_keywords, commit_fix_status_id, commit_fix_done_ratio settings
4 4
    # with commit_update_keywords setting
5
    keywords = Setting.where(:name => 'commit_fix_keywords').limit(1).pluck(:value).first
6
    status_id = Setting.where(:name => 'commit_fix_status_id').limit(1).pluck(:value).first
7
    done_ratio = Setting.where(:name => 'commit_fix_done_ratio').limit(1).pluck(:value).first
5
    keywords = Setting.where(:name => 'commit_fix_keywords').pick(:value)
6
    status_id = Setting.where(:name => 'commit_fix_status_id').pick(:value)
7
    done_ratio = Setting.where(:name => 'commit_fix_done_ratio').pick(:value)
8 8
    if keywords.present?
9 9
      Setting.commit_update_keywords = [{'keywords' => keywords, 'status_id' => status_id, 'done_ratio' => done_ratio}]
10 10
    end
db/migrate/20141029181752_add_trackers_default_status_id.rb
2 2
  def up
3 3
    add_column :trackers, :default_status_id, :integer
4 4

  
5
    status_id = IssueStatus.where(:is_default => true).pluck(:id).first
6
    status_id ||= IssueStatus.order(:position).pluck(:id).first
5
    status_id = IssueStatus.where(:is_default => true).pick(:id)
6
    status_id ||= IssueStatus.order(:position).pick(:id)
7 7
    if status_id
8 8
      Tracker.update_all :default_status_id => status_id
9 9
    end
db/migrate/20141029181824_remove_issue_statuses_is_default.rb
6 6
  def down
7 7
    add_column :issue_statuses, :is_default, :boolean, :null => false, :default => false
8 8
    # Restores the first status as default
9
    default_status_id = IssueStatus.order(:position).pluck(:id).first
9
    default_status_id = IssueStatus.order(:position).pick(:id)
10 10
    IssueStatus.where(:id => default_status_id).update_all(:is_default => true)
11 11
  end
12 12
end
lib/redmine/nested_set/issue_nested_set.rb
147 147
      end
148 148

  
149 149
      def reload_nested_set_values
150
        self.root_id, self.lft, self.rgt = self.class.where(:id => id).pluck(:root_id, :lft, :rgt).first
150
        self.root_id, self.lft, self.rgt = self.class.where(:id => id).pick(:root_id, :lft, :rgt)
151 151
      end
152 152

  
153 153
      def save_nested_set_values
lib/redmine/nested_set/project_nested_set.rb
44 44
        if siblings_rgt
45 45
          siblings_rgt + 1
46 46
        elsif parent_id
47
          parent_lft = self.class.where(:id => parent_id).pluck(:lft).first
47
          parent_lft = self.class.where(:id => parent_id).pick(:lft)
48 48
          unless parent_lft
49 49
            raise "Project id=#{id} with parent_id=#{parent_id}: parent missing or without 'lft' value"
50 50
          end
......
136 136
      end
137 137

  
138 138
      def reload_nested_set_values
139
        self.lft, self.rgt = Project.where(:id => id).pluck(:lft, :rgt).first
139
        self.lft, self.rgt = Project.where(:id => id).pick(:lft, :rgt)
140 140
      end
141 141

  
142 142
      def save_nested_set_values
(3-3/3)