diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/models/todo.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/models/todo.rb')
-rw-r--r-- | app/models/todo.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/app/models/todo.rb b/app/models/todo.rb index dc42551f0ab..102f36a991e 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -66,6 +66,8 @@ class Todo < ApplicationRecord scope :with_entity_associations, -> { preload(:target, :author, :note, group: :route, project: [:route, { namespace: :route }]) } scope :joins_issue_and_assignees, -> { left_joins(issue: :assignees) } + enum resolved_by_action: { system_done: 0, api_all_done: 1, api_done: 2, mark_all_done: 3, mark_done: 4 }, _prefix: :resolved_by + state_machine :state, initial: :pending do event :done do transition [:pending] => :done @@ -100,17 +102,17 @@ class Todo < ApplicationRecord state.nil? ? exists?(target: target) : exists?(target: target, state: state) end - # Updates the state of a relation of todos to the new state. + # Updates attributes of a relation of todos to the new state. # - # new_state - The new state of the todos. + # new_attributes - The new attributes of the todos. # # Returns an `Array` containing the IDs of the updated todos. - def update_state(new_state) - # Only update those that are not really on that state - base = where.not(state: new_state).except(:order) + def batch_update(**new_attributes) + # Only update those that have different state + base = where.not(state: new_attributes[:state]).except(:order) ids = base.pluck(:id) - base.update_all(state: new_state, updated_at: Time.now) + base.update_all(new_attributes.merge(updated_at: Time.current)) ids end @@ -187,6 +189,10 @@ class Todo < ApplicationRecord target_type == DesignManagement::Design.name end + def for_alert? + target_type == AlertManagement::Alert.name + end + # override to return commits, which are not active record def target if for_commit? |