Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormicael.bergeron <micaelbergeron@gmail.com>2017-12-06 18:57:10 +0300
committermicael.bergeron <micaelbergeron@gmail.com>2017-12-07 17:02:55 +0300
commit17075a0bdc0c271e9f7a4f25829c0517656d5871 (patch)
tree6b49ff0f910fd95063d9526e35c5b26c51628f3b /app/models/note.rb
parent16c8b91092fa0fe0b5822648c22ee545e11cb4bc (diff)
cache the Note#commit method
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index fb4a52f8c6e..c4c2ab8e67d 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -231,19 +231,17 @@ class Note < ActiveRecord::Base
end
def commit
- project.commit(commit_id) if commit_id.present?
+ @commit ||= project.commit(commit_id) if commit_id.present?
end
# override to return commits, which are not active record
def noteable
- if for_commit?
- @commit ||= commit
- else
- super
- end
- # Temp fix to prevent app crash
- # if note commit id doesn't exist
+ return commit if for_commit?
+
+ super
rescue
+ # Temp fix to prevent app crash
+ # if note commit id doesn't exist
nil
end