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/finders/issuables/crm_contact_filter.rb')
-rw-r--r--app/finders/issuables/crm_contact_filter.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/finders/issuables/crm_contact_filter.rb b/app/finders/issuables/crm_contact_filter.rb
new file mode 100644
index 00000000000..bea5f7d2bfa
--- /dev/null
+++ b/app/finders/issuables/crm_contact_filter.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+module Issuables
+ class CrmContactFilter < BaseFilter
+ def filter(issuables)
+ by_crm_contact(issuables)
+ end
+
+ # rubocop: disable CodeReuse/ActiveRecord
+ def by_crm_contact(issuables)
+ return issuables if params[:crm_contact_id].blank?
+
+ condition = CustomerRelations::IssueContact
+ .where(contact_id: params[:crm_contact_id])
+ .where(Arel.sql("issue_id = issues.id"))
+ issuables.where(condition.arel.exists)
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
+ end
+end