{"action":"opened","issue":{"url":"https://api.github.com/repos/collectiveidea/awesome_nested_set/issues/395","repository_url":"https://api.github.com/repos/collectiveidea/awesome_nested_set","labels_url":"https://api.github.com/repos/collectiveidea/awesome_nested_set/issues/395/labels{/name}","comments_url":"https://api.github.com/repos/collectiveidea/awesome_nested_set/issues/395/comments","events_url":"https://api.github.com/repos/collectiveidea/awesome_nested_set/issues/395/events","html_url":"https://github.com/collectiveidea/awesome_nested_set/issues/395","id":392114690,"node_id":"MDU6SXNzdWUzOTIxMTQ2OTA=","number":395,"title":"Preloading all ancestors","user":{"login":"stem","id":2844,"node_id":"MDQ6VXNlcjI4NDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/2844?v=4","gravatar_id":"","url":"https://api.github.com/users/stem","html_url":"https://github.com/stem","followers_url":"https://api.github.com/users/stem/followers","following_url":"https://api.github.com/users/stem/following{/other_user}","gists_url":"https://api.github.com/users/stem/gists{/gist_id}","starred_url":"https://api.github.com/users/stem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stem/subscriptions","organizations_url":"https://api.github.com/users/stem/orgs","repos_url":"https://api.github.com/users/stem/repos","events_url":"https://api.github.com/users/stem/events{/privacy}","received_events_url":"https://api.github.com/users/stem/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-18T11:32:19Z","updated_at":"2018-12-18T11:32:19Z","closed_at":null,"author_association":"NONE","body":"Hi folks,\r\n\r\nAt solidusio/solidus#3004, we have a use case for which I can't find a good solution and I would like your advices.\r\n\r\nWe have many taxonomies, and each taxonomy is a nested set of taxons.\r\nTaxons can be any depth level so they have ancestors.\r\n\r\nWe have an API endpoint where the user can ask for multiple taxons at once and we generate a \"pretty name\" for each one in the form of `Ancestor3 > Ancestor2 > Ancestor1 > LeafTaxon`.\r\nTo do that, we use the `ancestors` method, but it generates a new SQL query for each taxon the user asked to retrieve : a typical N+1 problem :/\r\n\r\nWhat I would like to do would be to `includes(:ancestors)` but it's not defined as an `has_many` and thus don't work.\r\n\r\nDo you have any tips on how to preload all ancestors of multiple taxons with the minimum amount of SQL queries ?"}}
{"actor":{"display_login":"stem"}}