payload: {"action":"created","issue":{"url":"https://api.github.com/repos/thepracticaldev/dev.to/issues/2525","repository_url":"https://api.github.com/repos/thepracticaldev/dev.to","labels_url":"https://api.github.com/repos/thepracticaldev/dev.to/issues/2525/labels{/name}","comments_url":"https://api.github.com/repos/thepracticaldev/dev.to/issues/2525/comments","events_url":"https://api.github.com/repos/thepracticaldev/dev.to/issues/2525/events","html_url":"https://github.com/thepracticaldev/dev.to/issues/2525","id":436193487,"node_id":"MDU6SXNzdWU0MzYxOTM0ODc=","number":2525,"title":"Some of the Notifications::NewReactionJobs fail with \"Validation failed\" on save!","user":{"login":"lightalloy","id":30115,"node_id":"MDQ6VXNlcjMwMTE1","avatar_url":"https://avatars2.githubusercontent.com/u/30115?v=4","gravatar_id":"","url":"https://api.github.com/users/lightalloy","html_url":"https://github.com/lightalloy","followers_url":"https://api.github.com/users/lightalloy/followers","following_url":"https://api.github.com/users/lightalloy/following{/other_user}","gists_url":"https://api.github.com/users/lightalloy/gists{/gist_id}","starred_url":"https://api.github.com/users/lightalloy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightalloy/subscriptions","organizations_url":"https://api.github.com/users/lightalloy/orgs","repos_url":"https://api.github.com/users/lightalloy/repos","events_url":"https://api.github.com/users/lightalloy/events{/privacy}","received_events_url":"https://api.github.com/users/lightalloy/received_events","type":"User","site_admin":false},"labels":[{"id":480869965,"node_id":"MDU6TGFiZWw0ODA4Njk5NjU=","url":"https://api.github.com/repos/thepracticaldev/dev.to/labels/bug","name":"bug","color":"C61C32","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2019-04-23T13:39:07Z","updated_at":"2019-05-27T10:46:54Z","closed_at":null,"author_association":"COLLABORATOR","body":"Some of the `Notifications::NewReactionJobs` fail with `Validation failed: User has already been taken` on `save!` in the `Notifications::Reactions::Send#call`\r\n\r\nMaybe it happens when a user creates several reactions on an article, several jobs are created, and those jobs run simultaneously.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/thepracticaldev/dev.to/issues/comments/496170084","html_url":"https://github.com/thepracticaldev/dev.to/issues/2525#issuecomment-496170084","issue_url":"https://api.github.com/repos/thepracticaldev/dev.to/issues/2525","id":496170084,"node_id":"MDEyOklzc3VlQ29tbWVudDQ5NjE3MDA4NA==","user":{"login":"lightalloy","id":30115,"node_id":"MDQ6VXNlcjMwMTE1","avatar_url":"https://avatars2.githubusercontent.com/u/30115?v=4","gravatar_id":"","url":"https://api.github.com/users/lightalloy","html_url":"https://github.com/lightalloy","followers_url":"https://api.github.com/users/lightalloy/followers","following_url":"https://api.github.com/users/lightalloy/following{/other_user}","gists_url":"https://api.github.com/users/lightalloy/gists{/gist_id}","starred_url":"https://api.github.com/users/lightalloy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightalloy/subscriptions","organizations_url":"https://api.github.com/users/lightalloy/orgs","repos_url":"https://api.github.com/users/lightalloy/repos","events_url":"https://api.github.com/users/lightalloy/events{/privacy}","received_events_url":"https://api.github.com/users/lightalloy/received_events","type":"User","site_admin":false},"created_at":"2019-05-27T10:46:54Z","updated_at":"2019-05-27T10:46:54Z","author_association":"COLLABORATOR","body":"The solutions could be:\r\n- `create_or_find_by` instead of `find_or_initialize_by` + second `save` (after assigning other attributes) inside a transaction (on Rails 6)\r\nor\r\n- use Postgres \"upsert\" (`INSERT ... ON CONFLICT UPDATE`). There's also a gem for that: https://github.com/jesjos/active_record_upsert\r\nIf we use the second option, we have to l avoid unique validation on `user` and rely on database constraint. \r\nWhile this is doable, I think it's an overkill for this specific issue, but can be used in the future if we have similar problems."}}
other: {"actor":{"display_login":"lightalloy"}}