Commit 37d7b0b8 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '31034-refactor-common-system-notes-service' into 'master'

Move `no_touching` to `CommonSystemNotesService`

See merge request gitlab-org/gitlab!20388
parents 072da402 4b54abfd
...@@ -7,20 +7,24 @@ module Issuable ...@@ -7,20 +7,24 @@ module Issuable
def execute(issuable, old_labels: [], is_update: true) def execute(issuable, old_labels: [], is_update: true)
@issuable = issuable @issuable = issuable
if is_update # We disable touch so that created system notes do not update
if issuable.previous_changes.include?('title') # the noteable's updated_at field
create_title_change_note(issuable.previous_changes['title'].first) ActiveRecord::Base.no_touching do
if is_update
if issuable.previous_changes.include?('title')
create_title_change_note(issuable.previous_changes['title'].first)
end
handle_description_change_note
handle_time_tracking_note if issuable.is_a?(TimeTrackable)
create_discussion_lock_note if issuable.previous_changes.include?('discussion_locked')
end end
handle_description_change_note create_due_date_note if issuable.previous_changes.include?('due_date')
create_milestone_note if issuable.previous_changes.include?('milestone_id')
handle_time_tracking_note if issuable.is_a?(TimeTrackable) create_labels_note(old_labels) if old_labels && issuable.labels != old_labels
create_discussion_lock_note if issuable.previous_changes.include?('discussion_locked')
end end
create_due_date_note if issuable.previous_changes.include?('due_date')
create_milestone_note if issuable.previous_changes.include?('milestone_id')
create_labels_note(old_labels) if old_labels && issuable.labels != old_labels
end end
private private
......
...@@ -164,9 +164,7 @@ class IssuableBaseService < BaseService ...@@ -164,9 +164,7 @@ class IssuableBaseService < BaseService
before_create(issuable) before_create(issuable)
if issuable.save if issuable.save
ActiveRecord::Base.no_touching do Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, is_update: false)
Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, is_update: false)
end
after_create(issuable) after_create(issuable)
execute_hooks(issuable) execute_hooks(issuable)
...@@ -227,10 +225,7 @@ class IssuableBaseService < BaseService ...@@ -227,10 +225,7 @@ class IssuableBaseService < BaseService
ensure_milestone_available(issuable) ensure_milestone_available(issuable)
if issuable.with_transaction_returning_status { issuable.save(touch: should_touch) } if issuable.with_transaction_returning_status { issuable.save(touch: should_touch) }
# We do not touch as it will affect a update on updated_at field Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, old_labels: old_associations[:labels])
ActiveRecord::Base.no_touching do
Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, old_labels: old_associations[:labels])
end
handle_changes(issuable, old_associations: old_associations) handle_changes(issuable, old_associations: old_associations)
...@@ -264,10 +259,7 @@ class IssuableBaseService < BaseService ...@@ -264,10 +259,7 @@ class IssuableBaseService < BaseService
before_update(issuable, skip_spam_check: true) before_update(issuable, skip_spam_check: true)
if issuable.with_transaction_returning_status { issuable.save } if issuable.with_transaction_returning_status { issuable.save }
# We do not touch as it will affect a update on updated_at field Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, old_labels: nil)
ActiveRecord::Base.no_touching do
Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, old_labels: nil)
end
handle_task_changes(issuable) handle_task_changes(issuable)
invalidate_cache_counts(issuable, users: issuable.assignees.to_a) invalidate_cache_counts(issuable, users: issuable.assignees.to_a)
......
...@@ -10,8 +10,10 @@ module EE ...@@ -10,8 +10,10 @@ module EE
def execute(_issuable, old_labels: [], is_update: true) def execute(_issuable, old_labels: [], is_update: true)
super super
handle_weight_change_note ActiveRecord::Base.no_touching do
handle_date_change_note if is_update handle_weight_change_note
handle_date_change_note if is_update
end
end end
private private
......
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