{"action":"closed","issue":{"url":"https://api.github.com/repos/Tsarpf/Tsatter/issues/3","labels_url":"https://api.github.com/repos/Tsarpf/Tsatter/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/Tsarpf/Tsatter/issues/3/comments","events_url":"https://api.github.com/repos/Tsarpf/Tsatter/issues/3/events","html_url":"https://github.com/Tsarpf/Tsatter/issues/3","id":54823741,"number":3,"title":"Room handling system needs a clean-up / rewrite","user":{"login":"Tsarpf","id":1676907,"avatar_url":"https://avatars.githubusercontent.com/u/1676907?v=3","gravatar_id":"","url":"https://api.github.com/users/Tsarpf","html_url":"https://github.com/Tsarpf","followers_url":"https://api.github.com/users/Tsarpf/followers","following_url":"https://api.github.com/users/Tsarpf/following{/other_user}","gists_url":"https://api.github.com/users/Tsarpf/gists{/gist_id}","starred_url":"https://api.github.com/users/Tsarpf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tsarpf/subscriptions","organizations_url":"https://api.github.com/users/Tsarpf/orgs","repos_url":"https://api.github.com/users/Tsarpf/repos","events_url":"https://api.github.com/users/Tsarpf/events{/privacy}","received_events_url":"https://api.github.com/users/Tsarpf/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-19T23:08:36Z","updated_at":"2015-02-08T21:07:19Z","closed_at":"2015-02-08T21:07:19Z","body":"First thing to do is move the mongoose interaction stuff (the findOneAndUpdate style stuff) to their own file and functions. Now the public interface functions contain stuff like:\r\n\r\n        User.findOne({name: username}).exec(function(err, doc) {\r\n            if(doc===null){\r\n                return;\r\n            }\r\n           //Add user to the room's user list\r\n           Room.findOneAndUpdate(\r\n           {name: mRoomName},\r\n           {$push: {users: {_id: doc._id}}}\r\n           ).exec(function(err, doc) {\r\n               if(err){\r\n                   console.log(err);\r\n               }\r\n               //console.log('saved user to channel');\r\n               //console.log(doc);\r\n           });\r\n        });\r\n\r\n\r\nwhich is over 10 lines of shit that could and should be condensed to:\r\n\r\npersistUserToChannel(user, roomname);\r\n\r\nwhere the function itself might be defined in a completely different file altogether?"}}