diff options
Diffstat (limited to 'app/models/user_interacted_project.rb')
-rw-r--r-- | app/models/user_interacted_project.rb | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/app/models/user_interacted_project.rb b/app/models/user_interacted_project.rb index ae6778e49be..308211c0b96 100644 --- a/app/models/user_interacted_project.rb +++ b/app/models/user_interacted_project.rb @@ -21,21 +21,19 @@ class UserInteractedProject < ActiveRecord::Base attributes = { project_id: event.project_id, - user_id: event.author_id + user_id: event.author_id, } cached_exists?(attributes) do transaction(requires_new: true) do - begin - where(attributes).select(1).first || create!(attributes) - true # not caching the whole record here for now - rescue ActiveRecord::RecordNotUnique - # Note, above queries are not atomic and prone - # to race conditions (similar like #find_or_create!). - # In the case where we hit this, the record we want - # already exists - shortcut and return. - true - end + where(attributes).select(1).first || create!(attributes) + true # not caching the whole record here for now + rescue ActiveRecord::RecordNotUnique + # Note, above queries are not atomic and prone + # to race conditions (similar like #find_or_create!). + # In the case where we hit this, the record we want + # already exists - shortcut and return. + true end end end |