summaryrefslogtreecommitdiffstats
path: root/lib/plugins
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2014-03-26 01:48:04 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2014-03-26 01:48:04 +0000
commit755108566c0c21760eeae17654ebd37767ed2b9c (patch)
tree5099b5dbf82ba4ff94ff574b77479aa349a273ca /lib/plugins
parent3c83d1c6464019dd0e1c8c0ca08798bb8570a6e0 (diff)
downloadredmine-755108566c0c21760eeae17654ebd37767ed2b9c.tar.gz
redmine-755108566c0c21760eeae17654ebd37767ed2b9c.zip
awesome_nested_set: split highest rgt reader method (#6579)
git-svn-id: http://svn.redmine.org/redmine/trunk@13010 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/plugins')
-rw-r--r--lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb b/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb
index 259de5a08..a6c7cf299 100644
--- a/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb
+++ b/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb
@@ -538,15 +538,18 @@ module CollectiveIdea #:nodoc:
end
end
- # on creation, set automatically lft and rgt to the end of the tree
- def set_default_left_and_right
- highest_right_row =
+ def right_most_bound
+ right_most_node =
self.class.base_class.unscoped.
order("#{quoted_right_column_full_name} desc").limit(1).lock(true).first
- maxright = highest_right_row ? (highest_right_row[right_column_name] || 0) : 0
+ right_most_node ? right_most_node[right_column_name] : 0
+ end
+
+ # on creation, set automatically lft and rgt to the end of the tree
+ def set_default_left_and_right
# adds the new node to the right of all existing nodes
- self[left_column_name] = maxright + 1
- self[right_column_name] = maxright + 2
+ self[left_column_name] = right_most_bound + 1
+ self[right_column_name] = right_most_bound + 2
end
def in_tenacious_transaction(&block)