summaryrefslogtreecommitdiff
path: root/app/models/concerns/has_integrations.rb
blob: 76e03d686006766f3d44574a2bfdd731d978dcbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module HasIntegrations
  extend ActiveSupport::Concern

  class_methods do
    def without_integration(integration)
      integrations = Integration
        .select('1')
        .where("#{Integration.table_name}.project_id = projects.id")
        .where(type: integration.type)

      Project
        .where('NOT EXISTS (?)', integrations)
        .where(pending_delete: false)
        .where(archived: false)
    end
  end
end