Commit 9ebbcb8f authored by Andreas Brandl's avatar Andreas Brandl

Operate on ids to avoid unnecessary loading.

parent 11a559f7
...@@ -2,8 +2,8 @@ class UserInteractedProject < ActiveRecord::Base ...@@ -2,8 +2,8 @@ class UserInteractedProject < ActiveRecord::Base
belongs_to :user belongs_to :user
belongs_to :project belongs_to :project
validates :project, presence: true validates :project_id, presence: true
validates :user, presence: true validates :user_id, presence: true
CACHE_EXPIRY_TIME = 1.day CACHE_EXPIRY_TIME = 1.day
...@@ -15,7 +15,7 @@ class UserInteractedProject < ActiveRecord::Base ...@@ -15,7 +15,7 @@ class UserInteractedProject < ActiveRecord::Base
# For events without a project, we simply don't care. # For events without a project, we simply don't care.
# An example of this is the creation of a snippet (which # An example of this is the creation of a snippet (which
# is not related to any project). # is not related to any project).
return unless event.project return unless event.project_id
# This is a precaution because the cache lookup # This is a precaution because the cache lookup
# will work just fine without an author. # will work just fine without an author.
......
...@@ -55,6 +55,6 @@ describe UserInteractedProject do ...@@ -55,6 +55,6 @@ describe UserInteractedProject do
end end
end end
it { is_expected.to validate_presence_of(:project) } it { is_expected.to validate_presence_of(:project_id) }
it { is_expected.to validate_presence_of(:user) } it { is_expected.to validate_presence_of(:user_id) }
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment