Operate on ids to avoid unnecessary loading.
This commit is contained in:
parent
11a559f7c9
commit
9ebbcb8f8b
2 changed files with 5 additions and 5 deletions
|
@ -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
|
||||||
# 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
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue