Welcome to mirror list, hosted at ThFree Co, Russian Federation.

crm_organization_filter.rb « issuables « finders « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f746049c405e82001d16481f5c957111e709d79d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module Issuables
  class CrmOrganizationFilter < BaseFilter
    def filter(issuables)
      by_crm_organization(issuables)
    end

    # rubocop: disable CodeReuse/ActiveRecord
    def by_crm_organization(issuables)
      return issuables if params[:crm_organization_id].blank?

      condition = CustomerRelations::IssueContact
        .joins(:contact)
        .where(contact: { organization_id: params[:crm_organization_id] })
        .where(Arel.sql("issue_id = issues.id"))
      issuables.where(condition.arel.exists)
    end
    # rubocop: enable CodeReuse/ActiveRecord
  end
end