]> source.dussan.org Git - redmine.git/commitdiff
Replace pluck().first with pick() (#32909).
authorGo MAEDA <maeda@farend.jp>
Sat, 3 Apr 2021 01:34:45 +0000 (01:34 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 3 Apr 2021 01:34:45 +0000 (01:34 +0000)
Patch by Pavel Rosický and Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@20907 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue_query.rb
app/models/user.rb
db/migrate/20131004113137_support_for_multiple_commit_keywords.rb
db/migrate/20141029181752_add_trackers_default_status_id.rb
db/migrate/20141029181824_remove_issue_statuses_is_default.rb
lib/redmine/nested_set/issue_nested_set.rb
lib/redmine/nested_set/project_nested_set.rb

index 5ff0e5530b2a33b9ba6cf4cd86952420c706d182..a2e821f9f94923680146b509a03f291a822e93c0 100644 (file)
@@ -599,7 +599,7 @@ class IssueQuery < Query
         "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
@@ -624,7 +624,7 @@ class IssueQuery < Query
         "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
index b25bab92625722e67d1debd7fb8d6eb175bca904..a3d2449d248b999882e2856eaf0cb5d2740ea687 100644 (file)
@@ -665,7 +665,7 @@ class User < Principal
       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").
index d8beb4aea952d9adc042dfa3e25138d0c6e1fafe..d7a9d5cc373bb280987bce079c514387d3a30851 100644 (file)
@@ -2,9 +2,9 @@ class SupportForMultipleCommitKeywords < ActiveRecord::Migration[4.2]
   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
index 74716ea632609368a6d57c3868811c1c50f4a30f..043be0c682eddb680cb41b78a25c65bfa11b40a1 100644 (file)
@@ -2,8 +2,8 @@ class AddTrackersDefaultStatusId < ActiveRecord::Migration[4.2]
   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
index 09808e31cc4bf072e66dda6602bd233de5bd01ab..94b518ea3414cb04a9930a01a498e9658a55e4c0 100644 (file)
@@ -6,7 +6,7 @@ class RemoveIssueStatusesIsDefault < ActiveRecord::Migration[4.2]
   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
index 4b97e1c19cc52cea3bc4d08fbaa5809744c0dc46..ba1c7a1de9764cd9135c39dbe7b8ab6719bb5909 100644 (file)
@@ -147,7 +147,7 @@ module Redmine
       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
index 13a63aca2d6dcd879faa0b37236e7135ff458138..e7b680fd104de83fcb1c9cd438f52a9ee1fcfdb2 100644 (file)
@@ -44,7 +44,7 @@ module Redmine
         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
@@ -136,7 +136,7 @@ module Redmine
       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