{"action":"created","issue":{"url":"https://api.github.com/repos/redcross/smoke-alarm-portal/issues/113","labels_url":"https://api.github.com/repos/redcross/smoke-alarm-portal/issues/113/labels{/name}","comments_url":"https://api.github.com/repos/redcross/smoke-alarm-portal/issues/113/comments","events_url":"https://api.github.com/repos/redcross/smoke-alarm-portal/issues/113/events","html_url":"https://github.com/redcross/smoke-alarm-portal/issues/113","id":103388433,"number":113,"title":"We still have \"assignedRegion\" in some source files.  Is it still used in Requests?","user":{"login":"kfogel","id":401111,"avatar_url":"https://avatars.githubusercontent.com/u/401111?v=3","gravatar_id":"","url":"https://api.github.com/users/kfogel","html_url":"https://github.com/kfogel","followers_url":"https://api.github.com/users/kfogel/followers","following_url":"https://api.github.com/users/kfogel/following{/other_user}","gists_url":"https://api.github.com/users/kfogel/gists{/gist_id}","starred_url":"https://api.github.com/users/kfogel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kfogel/subscriptions","organizations_url":"https://api.github.com/users/kfogel/orgs","repos_url":"https://api.github.com/users/kfogel/repos","events_url":"https://api.github.com/users/kfogel/events{/privacy}","received_events_url":"https://api.github.com/users/kfogel/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/redcross/smoke-alarm-portal/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-26T23:46:06Z","updated_at":"2015-08-27T01:55:17Z","closed_at":null,"body":"Although `models/request.js` does not have an `assignedRegion` field for the Request model, we still seem to have that field in the code in various places.  I originally started investigating why it looked like Requests had both `rc_region` (as expected) *and* `assignedRegion` (I wasn't sure what that was for, or if it was redundant with `rc_region`).  Then when I looked at the model, `assignedRegion` was not there (whew) but was still present in various places in the code (hmm).  What's going on?\r\n\r\n        models/index.js:db.Request.belongsTo(db.SelectedCounties, {foreignKey:'assignedRegion'});\r\n        models/index.js:db.SelectedCounties.hasMany(db.Request, {foreignKey:'assignedRegion'});\r\n        public/views/admin/requests/index.js:      assignedRegion: '',\r\n        public/views/admin/requests/index.min.js:!function(){\"use strict\";app=app||{},app.Record=Backbone.Model.extend({idAttribute:\"id\",defaults:{id:void 0,name:\"\",address:\"\",address_2:\"\",city:\"\",state:\"\",zip:\"\",phone:\"\",email:\"\",assignedRegion:\"\",selectedCount\r\n        public/views/admin/requests/index.min.js.map:{\"version\":3,\"file\":\"index.min.js\",\"sources\":[\"index.js\"],\"names\":[\"app\",\"Record\",\"Backbone\",\"Model\",\"extend\",\"idAttribute\",\"defaults\",\"id\",\"undefined\",\"name\",\"address\",\"address_2\",\"city\",\"state\",\"zip\",\"phone\"\r\n        views/index.js:    request.assignedRegion = region.id;\r\n        views/index.js:    return request.save({fields: ['assignedRegion']});\r\n\r\n(Similarly to the situation in issue #112, not all of the result lines above show the string \"assignedRegion\", but that's only because the results are truncated here -- if the file+line is listed, it means there will be a match there when we go into the file itself.)"},"comment":{"url":"https://api.github.com/repos/redcross/smoke-alarm-portal/issues/comments/135239628","html_url":"https://github.com/redcross/smoke-alarm-portal/issues/113#issuecomment-135239628","issue_url":"https://api.github.com/repos/redcross/smoke-alarm-portal/issues/113","id":135239628,"user":{"login":"kfogel","id":401111,"avatar_url":"https://avatars.githubusercontent.com/u/401111?v=3","gravatar_id":"","url":"https://api.github.com/users/kfogel","html_url":"https://github.com/kfogel","followers_url":"https://api.github.com/users/kfogel/followers","following_url":"https://api.github.com/users/kfogel/following{/other_user}","gists_url":"https://api.github.com/users/kfogel/gists{/gist_id}","starred_url":"https://api.github.com/users/kfogel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kfogel/subscriptions","organizations_url":"https://api.github.com/users/kfogel/orgs","repos_url":"https://api.github.com/users/kfogel/repos","events_url":"https://api.github.com/users/kfogel/events{/privacy}","received_events_url":"https://api.github.com/users/kfogel/received_events","type":"User","site_admin":false},"created_at":"2015-08-27T01:55:17Z","updated_at":"2015-08-27T01:55:17Z","body":"It helps, thanks so much!  (The string \"assignedRegion\" does not appear in issue #99, until the reference to this issue, so that's probably why my scan didn't clarify things for me).\r\n\r\nI don't understand how `assignedRegion` is being used to link to SelectedCounties given that in `data/selected_counties.js`, we are clearly using `rc_region`-style codes.  In other words, both our Requests model and the SelectedCounties model natively use `rc_region` anyway, or at least the model for the former and the static source data for the latter do.  It seems to me there should be no need to introduce an `assignedRegion` numeric code into this mix -- we already have the mapping we want \"for free\".  It is kind of premature optimization to add in a numeric code when there is no evidence we would have a performance problem.\r\n\r\nSo we should have one code-wise representation of Red Cross regions, and it should be the `rc_region` code (that is, a text field), and it should be used in the Requests model, the SelectedCounties model, and (eventually I guess we'll want this) maybe a separate model that just maps between `rc_region` codes and display names like \"Eastern Missouri\", etc.\r\n\r\nDoes this make sense?"}}