summaryrefslogtreecommitdiff
path: root/app/models/issue_assignee.rb
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2017-05-04 15:11:15 +0300
committerValery Sizov <valery@gitlab.com>2017-05-04 17:11:53 +0300
commit387c4b2c21a44360386a9b8ce6849e7f1b8a3de9 (patch)
tree446b8338efe8ad22ca03b00b2dc72b22c4174e02 /app/models/issue_assignee.rb
parent68c12e15cc236548918f91393ebef3c06c124814 (diff)
downloadgitlab-ce-387c4b2c21a44360386a9b8ce6849e7f1b8a3de9.tar.gz
Backport of multiple_assignees_feature [ci skip]
Diffstat (limited to 'app/models/issue_assignee.rb')
-rw-r--r--app/models/issue_assignee.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/models/issue_assignee.rb b/app/models/issue_assignee.rb
new file mode 100644
index 00000000000..b94b55bb1d1
--- /dev/null
+++ b/app/models/issue_assignee.rb
@@ -0,0 +1,29 @@
+class IssueAssignee < ActiveRecord::Base
+ extend Gitlab::CurrentSettings
+
+ belongs_to :issue
+ belongs_to :assignee, class_name: "User", foreign_key: :user_id
+
+ after_create :update_assignee_cache_counts
+ after_destroy :update_assignee_cache_counts
+
+ # EE-specific
+ after_create :update_elasticsearch_index
+ after_destroy :update_elasticsearch_index
+ # EE-specific
+
+ def update_assignee_cache_counts
+ assignee&.update_cache_counts
+ end
+
+ def update_elasticsearch_index
+ if current_application_settings.elasticsearch_indexing?
+ ElasticIndexerWorker.perform_async(
+ :update,
+ 'Issue',
+ issue.id,
+ changed_fields: ['assignee_ids']
+ )
+ end
+ end
+end