{"action":"created","issue":{"url":"https://api.github.com/repos/code-corps/code-corps-api/issues/252","repository_url":"https://api.github.com/repos/code-corps/code-corps-api","labels_url":"https://api.github.com/repos/code-corps/code-corps-api/issues/252/labels{/name}","comments_url":"https://api.github.com/repos/code-corps/code-corps-api/issues/252/comments","events_url":"https://api.github.com/repos/code-corps/code-corps-api/issues/252/events","html_url":"https://github.com/code-corps/code-corps-api/pull/252","id":136529779,"number":252,"title":"Add status field to user mentions. Change behavior so only old mentions of the same status are destroyed on regeneration","user":{"login":"begedin","id":1925540,"avatar_url":"https://avatars.githubusercontent.com/u/1925540?v=3","gravatar_id":"","url":"https://api.github.com/users/begedin","html_url":"https://github.com/begedin","followers_url":"https://api.github.com/users/begedin/followers","following_url":"https://api.github.com/users/begedin/following{/other_user}","gists_url":"https://api.github.com/users/begedin/gists{/gist_id}","starred_url":"https://api.github.com/users/begedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/begedin/subscriptions","organizations_url":"https://api.github.com/users/begedin/orgs","repos_url":"https://api.github.com/users/begedin/repos","events_url":"https://api.github.com/users/begedin/events{/privacy}","received_events_url":"https://api.github.com/users/begedin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/code-corps/code-corps-api/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-25T22:22:30Z","updated_at":"2016-02-25T22:37:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/code-corps/code-corps-api/pulls/252","html_url":"https://github.com/code-corps/code-corps-api/pull/252","diff_url":"https://github.com/code-corps/code-corps-api/pull/252.diff","patch_url":"https://github.com/code-corps/code-corps-api/pull/252.patch"},"body":"This is done and the specs cover the behavior, but I would like to check for some refactoring potential before merging tomorrow. Here's what we have:\r\n\r\n* `GET /comment_user_mentions` endpoint\r\n* `GET /post_user_mentions` endpoint\r\n* both endpoint accept a `comment/post_id` and a `status` parameter\r\n* neither of the endpoints requires logging in\r\n\r\n* modified behavior of scenarios for generating user mentions\r\n  * if we're publishing a post, mentions are generated from `body` and old mentions with status `published` are being destroyed.\r\n  * if we're previewing a post, mentions are generated from `body_preview` and old mentions with status `preview` are being destroyed\r\n\r\n* the `update` method has been modified further. It now calls the generation of mentions explicitly, instead of this being left to `after_save`. The reason for that is, we have to pass in a boolean to indicate if we're doing it for a publish or a preview. **This is the main thing I would like to rewrite in a nicer way**."},"comment":{"url":"https://api.github.com/repos/code-corps/code-corps-api/issues/comments/189015181","html_url":"https://github.com/code-corps/code-corps-api/pull/252#issuecomment-189015181","issue_url":"https://api.github.com/repos/code-corps/code-corps-api/issues/252","id":189015181,"user":{"login":"JoshSmith","id":321667,"avatar_url":"https://avatars.githubusercontent.com/u/321667?v=3","gravatar_id":"","url":"https://api.github.com/users/JoshSmith","html_url":"https://github.com/JoshSmith","followers_url":"https://api.github.com/users/JoshSmith/followers","following_url":"https://api.github.com/users/JoshSmith/following{/other_user}","gists_url":"https://api.github.com/users/JoshSmith/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshSmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshSmith/subscriptions","organizations_url":"https://api.github.com/users/JoshSmith/orgs","repos_url":"https://api.github.com/users/JoshSmith/repos","events_url":"https://api.github.com/users/JoshSmith/events{/privacy}","received_events_url":"https://api.github.com/users/JoshSmith/received_events","type":"User","site_admin":false},"created_at":"2016-02-25T22:37:10Z","updated_at":"2016-02-25T22:37:10Z","body":"Moving this out of `after_save` seems like a dangerous thing to do, given that we used that lifecycle hook to explicitly ensure that generated user mentions were wrapped in a transaction. If the generation of these mentions failed, we would get a record rollback.\r\n\r\nIs there no way to keep this method inside `after_save`?"}}