summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-03-30 19:33:45 -0600
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-05 17:44:14 +0100
commitbb8cc946689bfafb1e3a65aa00b8e75fb8a5006b (patch)
treec63719f281b3e38c149ce8a7425d826850914f80 /app/models/note.rb
parent2058e71e63c9ac471137f831b4d04b6626968532 (diff)
downloadgitlab-ce-bb8cc946689bfafb1e3a65aa00b8e75fb8a5006b.tar.gz
Don't use original_discussion_id
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb27
1 files changed, 3 insertions, 24 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index eef868a05d6..3db1656ba57 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -52,7 +52,7 @@ class Note < ActiveRecord::Base
validates :noteable_id, presence: true, unless: [:for_commit?, :importing?]
validates :commit_id, presence: true, if: :for_commit?
validates :author, presence: true
- validates :discussion_id, :original_discussion_id, presence: true, format: { with: /\A\h{40}\z/ }
+ validates :discussion_id, presence: true, format: { with: /\A\h{40}\z/ }
validate unless: [:for_commit?, :importing?, :for_personal_snippet?] do |note|
unless note.noteable.try(:project) == note.project
@@ -84,9 +84,9 @@ class Note < ActiveRecord::Base
project: [:project_members, { group: [:group_members] }])
end
- after_initialize :ensure_discussion_id, :ensure_original_discussion_id
+ after_initialize :ensure_discussion_id
before_validation :nullify_blank_type, :nullify_blank_line_code
- before_validation :set_discussion_id, :set_original_discussion_id, on: :create
+ before_validation :set_discussion_id, on: :create
after_save :keep_around_commit, unless: :for_personal_snippet?
after_save :expire_etag_cache
@@ -99,13 +99,6 @@ class Note < ActiveRecord::Base
Discussion.build_collection(fresh, noteable)
end
- def find_original_discussion(discussion_id)
- note = find_by(original_discussion_id: discussion_id)
- return unless note
-
- note.to_discussion
- end
-
def find_discussion(discussion_id)
notes = where(discussion_id: discussion_id).fresh.to_a
return if notes.empty?
@@ -309,20 +302,6 @@ class Note < ActiveRecord::Base
self.discussion_id ||= discussion_class.discussion_id(self)
end
- def ensure_original_discussion_id
- return unless self.persisted?
- # Needed in case the SELECT statement doesn't ask for `original_discussion_id`
- return unless self.has_attribute?(:original_discussion_id)
- return if self.original_discussion_id
-
- set_original_discussion_id
- update_column(:original_discussion_id, self.original_discussion_id)
- end
-
- def set_original_discussion_id
- self.original_discussion_id = discussion_class.original_discussion_id(self)
- end
-
def expire_etag_cache
return unless for_issue?