Class: Gitlab::Triage::Filters::MemberConditionsFilter
Constant Summary
collapse
- SOURCES =
%w[project group].freeze
- CONDITIONS =
%w[member_of not_member_of].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
all_params_filter_names, params_check_for_field, params_checking_condition_type, params_checking_condition_value, params_filter_names, #validate_condition
Constructor Details
#initialize(resource, condition, network = nil) ⇒ MemberConditionsFilter
Returns a new instance of MemberConditionsFilter.
13
14
15
16
|
# File 'lib/gitlab/triage/filters/member_conditions_filter.rb', line 13
def initialize(resource, condition, network = nil)
@network = network
super(resource, condition)
end
|
Class Method Details
.filter_parameters ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/gitlab/triage/filters/member_conditions_filter.rb', line 18
def self.filter_parameters
[
{
name: :source,
type: String,
values: SOURCES
},
{
name: :condition,
type: String,
values: CONDITIONS
},
{
name: :source_id,
type: [Numeric, String]
}
]
end
|
Instance Method Details
#calculate ⇒ Object
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/gitlab/triage/filters/member_conditions_filter.rb', line 51
def calculate
return false unless resource_value
case @condition
when :member_of
condition_value.include?(resource_value)
when :not_member_of
condition_value.exclude?(resource_value)
end
end
|
#condition_value ⇒ Object
47
48
49
|
# File 'lib/gitlab/triage/filters/member_conditions_filter.rb', line 47
def condition_value
members.pluck(:username)
end
|
#initialize_variables(condition) ⇒ Object
37
38
39
40
41
|
# File 'lib/gitlab/triage/filters/member_conditions_filter.rb', line 37
def initialize_variables(condition)
@source = condition[:source].to_sym
@condition = condition[:condition].to_sym
@source_id = condition[:source_id]
end
|
#members ⇒ Object
62
63
64
|
# File 'lib/gitlab/triage/filters/member_conditions_filter.rb', line 62
def members
@members ||= @network.query_api_cached(member_url)
end
|
#resource_value ⇒ Object
43
44
45
|
# File 'lib/gitlab/triage/filters/member_conditions_filter.rb', line 43
def resource_value
@resource[member_field][:username] if @resource[member_field]
end
|
#url_opts ⇒ Object
72
73
74
75
76
77
78
79
80
|
# File 'lib/gitlab/triage/filters/member_conditions_filter.rb', line 72
def url_opts
{
network_options: @network.options,
resource_type: 'members',
source: @source == :group ? 'groups' : 'projects',
source_id: @source_id,
params: { per_page: 100 }
}
end
|