blob: 9f511be0ace2816a3f2858bd7732c75ade8a4390 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# frozen_string_literal: true
module AlertManagement
class HttpIntegrationsFinder
def initialize(project, params)
@project = project
@params = params
end
def execute
@collection = project.alert_management_http_integrations
filter_by_availability
filter_by_endpoint_identifier
filter_by_active
collection
end
private
attr_reader :project, :params, :collection
def filter_by_availability
return if multiple_alert_http_integrations?
first_id = project.alert_management_http_integrations
.ordered_by_id
.select(:id)
.at_most(1)
@collection = collection.id_in(first_id)
end
def filter_by_endpoint_identifier
return unless params[:endpoint_identifier]
@collection = collection.for_endpoint_identifier(params[:endpoint_identifier])
end
def filter_by_active
return unless params[:active]
@collection = collection.active
end
# Overridden in EE
def multiple_alert_http_integrations?
false
end
end
end
::AlertManagement::HttpIntegrationsFinder.prepend_if_ee('EE::AlertManagement::HttpIntegrationsFinder')
|