diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2020-07-03 11:45:29 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2020-07-03 11:45:29 +0000 |
commit | e5371b4c67139996a70c0e338d4b2677b2ac3b87 (patch) | |
tree | f36c6d74da9df9f90ca0696c8361015fa4744645 /lib | |
parent | cb568dfd567c34048cc358a999c5fe4630ef5991 (diff) | |
download | redmine-e5371b4c67139996a70c0e338d4b2677b2ac3b87.tar.gz redmine-e5371b4c67139996a70c0e338d4b2677b2ac3b87.zip |
fix source indent of lib/redmine/nested_set/project_nested_set.rb
git-svn-id: http://svn.redmine.org/redmine/trunk@19849 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/nested_set/project_nested_set.rb | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/lib/redmine/nested_set/project_nested_set.rb b/lib/redmine/nested_set/project_nested_set.rb index 1d22e11fb..55b952f5d 100644 --- a/lib/redmine/nested_set/project_nested_set.rb +++ b/lib/redmine/nested_set/project_nested_set.rb @@ -51,11 +51,13 @@ module Redmine lock_nested_set if lock self.lft = target_lft self.rgt = lft + 1 - self.class.where("lft >= ? OR rgt >= ?", lft, lft).update_all([ - "lft = CASE WHEN lft >= :lft THEN lft + 2 ELSE lft END, " + - "rgt = CASE WHEN rgt >= :lft THEN rgt + 2 ELSE rgt END", - {:lft => lft} - ]) + self.class.where("lft >= ? OR rgt >= ?", lft, lft).update_all( + [ + "lft = CASE WHEN lft >= :lft THEN lft + 2 ELSE lft END, " + + "rgt = CASE WHEN rgt >= :lft THEN rgt + 2 ELSE rgt END", + {:lft => lft} + ] + ) end def move_in_nested_set @@ -69,19 +71,23 @@ module Redmine # Moving to the right d = c - (b - a + 1) scope = self.class.where(["lft BETWEEN :a AND :c - 1 OR rgt BETWEEN :a AND :c - 1", {:a => a, :c => c}]) - scope.update_all([ - "lft = CASE WHEN lft BETWEEN :a AND :b THEN lft + (:d - :a) WHEN lft BETWEEN :b + 1 AND :c - 1 THEN lft - (:b - :a + 1) ELSE lft END, " + - "rgt = CASE WHEN rgt BETWEEN :a AND :b THEN rgt + (:d - :a) WHEN rgt BETWEEN :b + 1 AND :c - 1 THEN rgt - (:b - :a + 1) ELSE rgt END", - {:a => a, :b => b, :c => c, :d => d} - ]) + scope.update_all( + [ + "lft = CASE WHEN lft BETWEEN :a AND :b THEN lft + (:d - :a) WHEN lft BETWEEN :b + 1 AND :c - 1 THEN lft - (:b - :a + 1) ELSE lft END, " + + "rgt = CASE WHEN rgt BETWEEN :a AND :b THEN rgt + (:d - :a) WHEN rgt BETWEEN :b + 1 AND :c - 1 THEN rgt - (:b - :a + 1) ELSE rgt END", + {:a => a, :b => b, :c => c, :d => d} + ] + ) elsif c < a # Moving to the left scope = self.class.where("lft BETWEEN :c AND :b OR rgt BETWEEN :c AND :b", {:a => a, :b => b, :c => c}) - scope.update_all([ - "lft = CASE WHEN lft BETWEEN :a AND :b THEN lft - (:a - :c) WHEN lft BETWEEN :c AND :a - 1 THEN lft + (:b - :a + 1) ELSE lft END, " + - "rgt = CASE WHEN rgt BETWEEN :a AND :b THEN rgt - (:a - :c) WHEN rgt BETWEEN :c AND :a - 1 THEN rgt + (:b - :a + 1) ELSE rgt END", - {:a => a, :b => b, :c => c, :d => d} - ]) + scope.update_all( + [ + "lft = CASE WHEN lft BETWEEN :a AND :b THEN lft - (:a - :c) WHEN lft BETWEEN :c AND :a - 1 THEN lft + (:b - :a + 1) ELSE lft END, " + + "rgt = CASE WHEN rgt BETWEEN :a AND :b THEN rgt - (:a - :c) WHEN rgt BETWEEN :c AND :a - 1 THEN rgt + (:b - :a + 1) ELSE rgt END", + {:a => a, :b => b, :c => c, :d => d} + ] + ) end reload_nested_set_values end @@ -94,11 +100,13 @@ module Redmine end children.each {|c| c.send :destroy_without_nested_set_update} unless @without_nested_set_update - self.class.where("lft > ? OR rgt > ?", lft, lft).update_all([ - "lft = CASE WHEN lft > :lft THEN lft - :shift ELSE lft END, " + - "rgt = CASE WHEN rgt > :lft THEN rgt - :shift ELSE rgt END", - {:lft => lft, :shift => rgt - lft + 1} - ]) + self.class.where("lft > ? OR rgt > ?", lft, lft).update_all( + [ + "lft = CASE WHEN lft > :lft THEN lft - :shift ELSE lft END, " + + "rgt = CASE WHEN rgt > :lft THEN rgt - :shift ELSE rgt END", + {:lft => lft, :shift => rgt - lft + 1} + ] + ) end end |