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:
Diffstat (limited to 'app/services/issuable_base_service.rb')
-rw-r--r--app/services/issuable_base_service.rb29
1 files changed, 20 insertions, 9 deletions
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb
index 6d41d449683..094b31b4ad6 100644
--- a/app/services/issuable_base_service.rb
+++ b/app/services/issuable_base_service.rb
@@ -190,11 +190,7 @@ class IssuableBaseService < BaseService
change_additional_attributes(issuable)
old_associations = associations_before_update(issuable)
- label_ids = process_label_ids(params, existing_label_ids: issuable.label_ids)
- if labels_changing?(issuable.label_ids, label_ids)
- params[:label_ids] = label_ids
- issuable.touch
- end
+ assign_requested_labels(issuable)
if issuable.changed? || params.present?
issuable.assign_attributes(params)
@@ -262,6 +258,11 @@ class IssuableBaseService < BaseService
invalidate_cache_counts(issuable, users: issuable.assignees.to_a)
after_update(issuable)
execute_hooks(issuable, 'update', old_associations: nil)
+
+ if issuable.is_a?(MergeRequest)
+ Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter
+ .track_task_item_status_changed(user: current_user)
+ end
end
end
@@ -297,10 +298,6 @@ class IssuableBaseService < BaseService
update_task(issuable)
end
- def labels_changing?(old_label_ids, new_label_ids)
- old_label_ids.sort != new_label_ids.sort
- end
-
def has_title_or_description_changed?(issuable)
issuable.title_changed? || issuable.description_changed?
end
@@ -349,6 +346,20 @@ class IssuableBaseService < BaseService
end
# rubocop: enable CodeReuse/ActiveRecord
+ def assign_requested_labels(issuable)
+ label_ids = process_label_ids(params, existing_label_ids: issuable.label_ids)
+ return unless ids_changing?(issuable.label_ids, label_ids)
+
+ params[:label_ids] = label_ids
+ issuable.touch
+ end
+
+ # Arrays of ids are used, but we should really use sets of ids, so
+ # let's have an helper to properly check if some ids are changing
+ def ids_changing?(old_array, new_array)
+ old_array.sort != new_array.sort
+ end
+
def toggle_award(issuable)
award = params.delete(:emoji_award)
AwardEmojis::ToggleService.new(issuable, award, current_user).execute if award