{"action":"created","issue":{"url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/864","repository_url":"https://api.github.com/repos/uktrade/data-hub-leeloo","labels_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/864/labels{/name}","comments_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/864/comments","events_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/864/events","html_url":"https://github.com/uktrade/data-hub-leeloo/pull/864","id":303867450,"number":864,"title":"Add sector hierarchy","user":{"login":"reupen","id":12693549,"avatar_url":"https://avatars1.githubusercontent.com/u/12693549?v=4","gravatar_id":"","url":"https://api.github.com/users/reupen","html_url":"https://github.com/reupen","followers_url":"https://api.github.com/users/reupen/followers","following_url":"https://api.github.com/users/reupen/following{/other_user}","gists_url":"https://api.github.com/users/reupen/gists{/gist_id}","starred_url":"https://api.github.com/users/reupen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reupen/subscriptions","organizations_url":"https://api.github.com/users/reupen/orgs","repos_url":"https://api.github.com/users/reupen/repos","events_url":"https://api.github.com/users/reupen/events{/privacy}","received_events_url":"https://api.github.com/users/reupen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-09T14:54:54Z","updated_at":"2018-03-12T11:05:32Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/864","html_url":"https://github.com/uktrade/data-hub-leeloo/pull/864","diff_url":"https://github.com/uktrade/data-hub-leeloo/pull/864.diff","patch_url":"https://github.com/uktrade/data-hub-leeloo/pull/864.patch"},"body":"Issue number: DH-1585\r\n\r\n### Description of change\r\n\r\nAdds a hierarchy to sectors using django-mptt.\r\n\r\nThe migration reloads the sectors with the hierarchy in place. (Note that sectors themselves won't be modified in production while this work is ongoing.) The name column has been removed from the model, but remains in the database for now so that we can deploy without any downtime.\r\n\r\nThe main complexity here is around generating the full name/path of each sector. In theory, it's possible to do so in the same query using StringAgg (string_agg()), but getting that working with the ORM and DRF is not straightforward. So a relatively efficient approach (taking into account pre-fetching) of walking up parent attributes was used instead. (Another option might be to save the generated names in the database, but we'd have to regenerate them when part of the tree changes.)\r\n\r\nThe metadata endpoint for sectors has been extended to include a few more fields. Otherwise, the API remains unchanged (i.e. these changes are backwards compatible).\r\n\r\nThere will be a follow-up PR to add a new filter to search making use of the hierarchy.\r\n\r\n### Checklist\r\n\r\n* [x] Have any relevant search models been updated?\r\n* [x] Have any relevant fixtures (`fixtures/test_data.yaml`) been updated?\r\n* [x] Have any relevant select-/prefetch-related field lists in the views and search apps been updated?\r\n* [x] Has the admin site been updated (for new models, fields etc.)?\r\n* [x] Has the README been updated (if needed)?\r\n"},"comment":{"url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/comments/372271819","html_url":"https://github.com/uktrade/data-hub-leeloo/pull/864#issuecomment-372271819","issue_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/864","id":372271819,"user":{"login":"elcct","id":5889630,"avatar_url":"https://avatars2.githubusercontent.com/u/5889630?v=4","gravatar_id":"","url":"https://api.github.com/users/elcct","html_url":"https://github.com/elcct","followers_url":"https://api.github.com/users/elcct/followers","following_url":"https://api.github.com/users/elcct/following{/other_user}","gists_url":"https://api.github.com/users/elcct/gists{/gist_id}","starred_url":"https://api.github.com/users/elcct/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elcct/subscriptions","organizations_url":"https://api.github.com/users/elcct/orgs","repos_url":"https://api.github.com/users/elcct/repos","events_url":"https://api.github.com/users/elcct/events{/privacy}","received_events_url":"https://api.github.com/users/elcct/received_events","type":"User","site_admin":false},"created_at":"2018-03-12T11:05:32Z","updated_at":"2018-03-12T11:05:32Z","author_association":"CONTRIBUTOR","body":"I am happy with `node_name`. Perhaps it reveals what is the implementation beneath it, as mptt uses node terminology or that we are using tree structure to store it, but I am curious what could be alternative as well?"}}
{"actor":{"display_login":"elcct"}}