-
Notifications
You must be signed in to change notification settings - Fork 239
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
List tree items only with associations (+counts) #114
Comments
This is a specific case, i don't think it good to add all the edge cases to the library. |
Isn't it a common case to build the select (options) or navigation trees? |
You can extend these methods : https://github.com/mceachen/closure_tree/blob/de3c605da9f24430c365b82a9c94bb81cd4e1c1e/lib/closure_tree/hash_tree.rb |
That's what I made actually. You can see it in the provided code above. But there are few drawbacks, that I've listed in the topic message. |
And i said that the extra customization is application specific and not general case. |
I would like to discuss with someone who also would like to see the same functionality in the |
Hi, I actually have to provide exactly this sort of metadata in my app as I found that when I was using mysql, the performance of the count() was If you went with this approach, you wouldn't have to pass a custom select |
👍 for this one. I also need this and currently I am using @dmitry's approach. |
Just to add: my idea is that if you have tag |
Rather than have this functionality in the library, would a plugin make sense here? In retrospect, all the deterministic ordering functionality, for example, was very invasive to this gem, and by having documented callback hooks, I may have been less complicated to have pulled it into a new sub-gem. What RDBMS are you guys using? |
MySQL here. |
@mceachen why not to make this code https://github.com/mceachen/closure_tree/blob/de3c605da9f24430c365b82a9c94bb81cd4e1c1e/lib/closure_tree/hash_tree.rb#L26 more flexible? |
@dmitry Do you want to send a PR with a more flexible approach ? |
@seuros not really, don't have a time right now, and I'm not required in such functionality anymore. Just a suggestion that it may be written in more flexible way (some parts of this big method may be extracted, as an example). |
Is there are some easy approach to get all the items of a tree as a nested hash (hash_tree) but only these that have any associations and return the number associated record to the item (with descendants)?
In my opinion it's a common task. How I'm doing it right now:
But I don't like it because:
Lets find the better solution and include it in the library.
The text was updated successfully, but these errors were encountered: