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,6 +7,9 @@ module Issuable ...@@ -7,6 +7,9 @@ module Issuable
def execute(issuable, old_labels: [], is_update: true) def execute(issuable, old_labels: [], is_update: true)
@issuable = issuable @issuable = issuable
# We disable touch so that created system notes do not update
# the noteable's updated_at field
ActiveRecord::Base.no_touching do
if is_update if is_update
if issuable.previous_changes.include?('title') if issuable.previous_changes.include?('title')
create_title_change_note(issuable.previous_changes['title'].first) create_title_change_note(issuable.previous_changes['title'].first)
...@@ -22,6 +25,7 @@ module Issuable ...@@ -22,6 +25,7 @@ module Issuable
create_milestone_note if issuable.previous_changes.include?('milestone_id') create_milestone_note if issuable.previous_changes.include?('milestone_id')
create_labels_note(old_labels) if old_labels && issuable.labels != old_labels create_labels_note(old_labels) if old_labels && issuable.labels != old_labels
end 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
ActiveRecord::Base.no_touching do
Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, old_labels: old_associations[:labels]) 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
ActiveRecord::Base.no_touching do
Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, old_labels: nil) 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,9 +10,11 @@ module EE ...@@ -10,9 +10,11 @@ module EE
def execute(_issuable, old_labels: [], is_update: true) def execute(_issuable, old_labels: [], is_update: true)
super super
ActiveRecord::Base.no_touching do
handle_weight_change_note handle_weight_change_note
handle_date_change_note if is_update 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