{"action":"created","issue":{"url":"https://api.github.com/repos/CLIxIndia-Dev/CLIxChat/issues/6","repository_url":"https://api.github.com/repos/CLIxIndia-Dev/CLIxChat","labels_url":"https://api.github.com/repos/CLIxIndia-Dev/CLIxChat/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/CLIxIndia-Dev/CLIxChat/issues/6/comments","events_url":"https://api.github.com/repos/CLIxIndia-Dev/CLIxChat/issues/6/events","html_url":"https://github.com/CLIxIndia-Dev/CLIxChat/issues/6","id":258852348,"number":6,"title":"Getting the \"root\" element?","user":{"login":"cjshawMIT","id":4930129,"avatar_url":"https://avatars0.githubusercontent.com/u/4930129?v=4","gravatar_id":"","url":"https://api.github.com/users/cjshawMIT","html_url":"https://github.com/cjshawMIT","followers_url":"https://api.github.com/users/cjshawMIT/followers","following_url":"https://api.github.com/users/cjshawMIT/following{/other_user}","gists_url":"https://api.github.com/users/cjshawMIT/gists{/gist_id}","starred_url":"https://api.github.com/users/cjshawMIT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjshawMIT/subscriptions","organizations_url":"https://api.github.com/users/cjshawMIT/orgs","repos_url":"https://api.github.com/users/cjshawMIT/repos","events_url":"https://api.github.com/users/cjshawMIT/events{/privacy}","received_events_url":"https://api.github.com/users/cjshawMIT/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-09-19T14:56:34Z","updated_at":"2017-09-19T15:14:52Z","closed_at":null,"author_association":"NONE","body":"So you'll have to educate me on this, but I'm unclear if this code does what you want it to (~lines 92-95):\r\n\r\n```\r\n        top_level_elements = Element.objects.filter(level=0) # this is a string not an element object\r\n        for x in top_level_elements:\r\n            if str.lower(x.name) == \"start\":\r\n                element = x\r\n```\r\n\r\nAre you trying to get the first `start` Element, or the last one, assigned to the `element` variable? If you really start supporting multiple dialog roots, won't you have to change this code to account for multiple `start` Elements? (and how would you do that? At the very least, you might need a `break` statement here, or otherwise grab the first one back from the queryset).\r\n\r\nThis also seems like an opportunity to break this code out into its own method and gave it a clarifying name. And of course, add a set of tests (when there are no elements named `start`, 1 element, multiple, etc.), depending on what is the current use case you're supposed to be supporting.\r\n\r\nRight now I think the `on_chat_message` method breaks if there are no elements named `start` (line 295, `user.last_node=element` might throw an exception), but maybe that's not a possible state to be in?"},"comment":{"url":"https://api.github.com/repos/CLIxIndia-Dev/CLIxChat/issues/comments/330572707","html_url":"https://github.com/CLIxIndia-Dev/CLIxChat/issues/6#issuecomment-330572707","issue_url":"https://api.github.com/repos/CLIxIndia-Dev/CLIxChat/issues/6","id":330572707,"user":{"login":"cjshawMIT","id":4930129,"avatar_url":"https://avatars0.githubusercontent.com/u/4930129?v=4","gravatar_id":"","url":"https://api.github.com/users/cjshawMIT","html_url":"https://github.com/cjshawMIT","followers_url":"https://api.github.com/users/cjshawMIT/followers","following_url":"https://api.github.com/users/cjshawMIT/following{/other_user}","gists_url":"https://api.github.com/users/cjshawMIT/gists{/gist_id}","starred_url":"https://api.github.com/users/cjshawMIT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjshawMIT/subscriptions","organizations_url":"https://api.github.com/users/cjshawMIT/orgs","repos_url":"https://api.github.com/users/cjshawMIT/repos","events_url":"https://api.github.com/users/cjshawMIT/events{/privacy}","received_events_url":"https://api.github.com/users/cjshawMIT/received_events","type":"User","site_admin":false},"created_at":"2017-09-19T15:14:52Z","updated_at":"2017-09-19T15:14:52Z","author_association":"NONE","body":"Or, if you're sticking with one dialog tree for now, just add in a `TODO` comment to refactor that section, when you need to support multiple dialog trees."}}
{"actor":{"display_login":"cjshawMIT"}}