Class: Gitlab::Triage::Filters::VotesConditionsFilter
Constant Summary
collapse
- ATTRIBUTES =
%w[upvotes downvotes].freeze
- CONDITIONS =
%w[greater_than less_than].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
all_params_filter_names, #initialize, params_check_for_field, params_checking_condition_type, params_checking_condition_value, params_filter_names, #validate_condition
Class Method Details
.filter_parameters ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/gitlab/triage/filters/votes_conditions_filter.rb', line 10
def self.filter_parameters
[
{
name: :attribute,
type: String,
values: ATTRIBUTES
},
{
name: :condition,
type: String,
values: CONDITIONS
},
{
name: :threshold,
type: Numeric
}
]
end
|
Instance Method Details
#calculate ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/gitlab/triage/filters/votes_conditions_filter.rb', line 43
def calculate
case @condition
when :greater_than
resource_value > condition_value
when :less_than
resource_value < condition_value
end
end
|
#condition_value ⇒ Object
39
40
41
|
# File 'lib/gitlab/triage/filters/votes_conditions_filter.rb', line 39
def condition_value
@threshold
end
|
#initialize_variables(condition) ⇒ Object
29
30
31
32
33
|
# File 'lib/gitlab/triage/filters/votes_conditions_filter.rb', line 29
def initialize_variables(condition)
@attribute = condition[:attribute].to_sym
@condition = condition[:condition].to_sym
@threshold = condition[:threshold]
end
|
#resource_value ⇒ Object
35
36
37
|
# File 'lib/gitlab/triage/filters/votes_conditions_filter.rb', line 35
def resource_value
@resource[@attribute]
end
|