-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix arrange/arrange_nodes methods filtering out some nodes. #363
Conversation
…ven't got it's parent included into input nodes collection (stefankroes#362)
@trafium this PR break the ordering for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the main thing we need is a failing test, so we don't introduce this again.
It seems very bizarre to have partial trees in the hash. I can see how that was missed.
arranged = ActiveSupport::OrderedHash.new | ||
min_depth = Float::INFINITY | ||
index = Hash.new { |h, k| h[k] = ActiveSupport::OrderedHash.new } | ||
arranged = ActiveSupport::OrderedHash.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hashes are ordered by default. can we just use a regular hash?
I think introduced in ruby version 1.9 ~12/2007
@@ -29,27 +29,25 @@ def orphan_strategy= orphan_strategy | |||
|
|||
# Arrangement | |||
def arrange options = {} | |||
# Get all nodes ordered by ancestry and start sorting them into an empty hash | |||
arrange_nodes self.ancestry_base_class.reorder(options.delete(:order)).where(options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how removing the ordering helps the pr
The issue with removing this ordering is the tree will still get created, but the nodes will not be in the secondary desired order.
Also of note, the ancestry column does not have c
collation. So I do not trust sql's order
right now.
Thank you for opening this PR. future suggestion: make a local branch rather than creating this on your master. I cant merge without a test, or with it breaking existing tests. Please reopen / ping me if you want to work through this @waqarbaig07 if you have a solution, please share |
#362