Skip to content
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

Question #508

Closed
b-ouinten opened this issue Sep 21, 2020 · 4 comments
Closed

Question #508

b-ouinten opened this issue Sep 21, 2020 · 4 comments

Comments

@b-ouinten
Copy link

b-ouinten commented Sep 21, 2020

Hi !

First of all, I intend to thank you for the gem, it helped me a lot. However, I am wondering if there is a pretty way to return only the deeper nodes. I tried the following : root.descendants.to_a.delete_if { |node| node.has_children? } but I think that isn't the efficient way as it took a long time to complete the process. I did a test with a tree containing 10000 nodes.

Thank you in advance.

@kevinluo201
Copy link

I think this the feature we all want, lol
I saw a couple of solutions in this repo by composing a great SQL, for example link, but they all have some constraints like the SQL is only valid in MySQL or PG

@kbrock
Copy link
Collaborator

kbrock commented Nov 2, 2020

I'm ok with pg or mysql specific changes.
I tried to put in place a pattern that allows us to have database specific changes.
at mixin time you don't have access to the database so we need to ask the user to take on that responsibility by passing it in or something like that.

its just the way we define these scopes and attributes that is troublesome, especially with rails 6.
And the to_node code at the beginning has issues.

I have a branch that introduces a new path format with a slash at the beginning and the end. this gets rid of the or and fixes a few things but I didn't get much performance differences.

I have a branch that stores with arrays which is pg only but has promise.

In the end I feel extracting the serialization format from our code makes sense. this would leverage the rails attribute api.

Still trying to figure out the full implications of this approach as it looks like it allows us to even have multiple parent trees (only one parent chain per tree, but multiple ancestry columns)

Not sure how clean the changes would be, especially since people tend to monkey patch this code a bunch.

@kbrock
Copy link
Collaborator

kbrock commented Nov 2, 2020

sorry - I had written that 11 days ago but hadn't clicked the submit button

@kbrock
Copy link
Collaborator

kbrock commented Jan 27, 2023

lets keep the discussion over in #246

@kbrock kbrock closed this as completed Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants