{"action":"created","issue":{"url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/102","labels_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/102/labels{/name}","comments_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/102/comments","events_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/102/events","html_url":"https://github.com/moneyadviceservice/mas-rad_core/pull/102","id":106995448,"number":102,"title":"We must use after commit hook for indexing to ElasticSearch","user":{"login":"munckymagik","id":306583,"avatar_url":"https://avatars.githubusercontent.com/u/306583?v=3","gravatar_id":"","url":"https://api.github.com/users/munckymagik","html_url":"https://github.com/munckymagik","followers_url":"https://api.github.com/users/munckymagik/followers","following_url":"https://api.github.com/users/munckymagik/following{/other_user}","gists_url":"https://api.github.com/users/munckymagik/gists{/gist_id}","starred_url":"https://api.github.com/users/munckymagik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/munckymagik/subscriptions","organizations_url":"https://api.github.com/users/munckymagik/orgs","repos_url":"https://api.github.com/users/munckymagik/repos","events_url":"https://api.github.com/users/munckymagik/events{/privacy}","received_events_url":"https://api.github.com/users/munckymagik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-17T14:19:13Z","updated_at":"2015-09-18T09:11:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/pulls/102","html_url":"https://github.com/moneyadviceservice/mas-rad_core/pull/102","diff_url":"https://github.com/moneyadviceservice/mas-rad_core/pull/102.diff","patch_url":"https://github.com/moneyadviceservice/mas-rad_core/pull/102.patch"},"body":"# The problem\r\n\r\nWe cannot use the `after_save` callback for reindexing. From the [Rails docs on after_save](http://apidock.com/rails/ActiveRecord/Callbacks/after_save)\r\n\r\n`\"Note that this callback is still wrapped in the transaction around save. For example, if you invoke an external indexer at this point it won’t see the changes in the database.\"`\r\n\r\n# What has changed?\r\n\r\n1. `Firm#publish_to_elastic_search` is now called on `after_commit` again unless the firm is being destroyed.\r\n2. Once the above was done, reindexing the previous parent firm for an adviser being moved stopped working as the `firm_id_changed?` method will return false after the transaction has been committed. So reverted previous commit to fix this behaviour."},"comment":{"url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/comments/141388896","html_url":"https://github.com/moneyadviceservice/mas-rad_core/pull/102#issuecomment-141388896","issue_url":"https://api.github.com/repos/moneyadviceservice/mas-rad_core/issues/102","id":141388896,"user":{"login":"darokel","id":616080,"avatar_url":"https://avatars.githubusercontent.com/u/616080?v=3","gravatar_id":"","url":"https://api.github.com/users/darokel","html_url":"https://github.com/darokel","followers_url":"https://api.github.com/users/darokel/followers","following_url":"https://api.github.com/users/darokel/following{/other_user}","gists_url":"https://api.github.com/users/darokel/gists{/gist_id}","starred_url":"https://api.github.com/users/darokel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darokel/subscriptions","organizations_url":"https://api.github.com/users/darokel/orgs","repos_url":"https://api.github.com/users/darokel/repos","events_url":"https://api.github.com/users/darokel/events{/privacy}","received_events_url":"https://api.github.com/users/darokel/received_events","type":"User","site_admin":false},"created_at":"2015-09-18T09:11:52Z","updated_at":"2015-09-18T09:11:52Z","body":":+1: "}}