Class: Gitlab::Triage::Limiters::DateFieldLimiter
- Inherits:
-
BaseLimiter
- Object
- BaseLimiter
- Gitlab::Triage::Limiters::DateFieldLimiter
show all
- Defined in:
- lib/gitlab/triage/limiters/date_field_limiter.rb
Constant Summary
collapse
- LIMITS =
%i[most_recent oldest].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseLimiter
#initialize, #validate_limit
Class Method Details
.limiter_parameters ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/gitlab/triage/limiters/date_field_limiter.rb', line 12
def self.limiter_parameters
[
{
name: :most_recent,
type: Integer
},
{
name: :oldest,
type: Integer
}
]
end
|
Instance Method Details
#initialize_resources(resources) ⇒ Object
41
42
43
|
# File 'lib/gitlab/triage/limiters/date_field_limiter.rb', line 41
def initialize_resources(resources)
resources.sort_by { |res| res[:created_at] }
end
|
#initialize_variables(limit) ⇒ Object
25
26
27
28
|
# File 'lib/gitlab/triage/limiters/date_field_limiter.rb', line 25
def initialize_variables(limit)
@criterion = LIMITS.find(&limit.method(:[]))
@threshold = limit[@criterion]
end
|
#limit ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/gitlab/triage/limiters/date_field_limiter.rb', line 30
def limit
case @criterion
when :oldest
@resources.first(@threshold)
when :most_recent
@resources.last(@threshold).reverse
end
end
|