diff options
Diffstat (limited to 'app/models/issue_assignee.rb')
-rw-r--r-- | app/models/issue_assignee.rb | 29 |
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 |