Class: Gitlab::Triage::Resource::Milestone
- Inherits:
-
Base
- Object
- Base
- Gitlab::Triage::Resource::Milestone
show all
- Defined in:
- lib/gitlab/triage/resource/milestone.rb
Constant Summary
collapse
- FIELDS =
%i[
id
iid
project_id
group_id
title
description
state
].freeze
- DATE_FIELDS =
%i[
due_date
start_date
].freeze
- TIME_FIELDS =
%i[
updated_at
created_at
].freeze
Constants inherited
from Base
Base::CONFIDENTIAL_TEXT
Instance Attribute Summary
Attributes inherited from Base
#parent, #resource
Instance Method Summary
collapse
Methods inherited from Base
#build_url, define_field, #expand_resource!, #initialize, #network, #redact_confidential_attributes?, #resource_id, #resource_url, #source, #source_resource, #source_url, #url, #url_opts
Instance Method Details
#active? ⇒ Boolean
57
58
59
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 57
def active?
state == 'active'
end
|
#all_active ⇒ Object
89
90
91
92
93
94
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 89
def all_active
@all_active ||=
network
.query_api_cached(url(state: 'active'))
.map { |milestone| self.class.new(milestone, parent: self) }
end
|
#all_active_with_start_date ⇒ Object
84
85
86
87
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 84
def all_active_with_start_date
@all_active_with_start_date ||=
all_active.select(&:start_date).sort_by(&:start_date)
end
|
#closed? ⇒ Boolean
61
62
63
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 61
def closed?
state == 'closed'
end
|
#current_index ⇒ Object
79
80
81
82
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 79
def current_index
all_active_with_start_date
.index { |milestone| milestone.id == id }
end
|
#expired?(today = Date.today) ⇒ Boolean
69
70
71
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 69
def expired?(today = Date.today)
due_date && due_date < today
end
|
#in_progress?(today = Date.today) ⇒ Boolean
73
74
75
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 73
def in_progress?(today = Date.today)
started?(today) && !expired?(today)
end
|
#started?(today = Date.today) ⇒ Boolean
65
66
67
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 65
def started?(today = Date.today)
start_date && start_date <= today
end
|
#succ ⇒ Object
51
52
53
54
55
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 51
def succ
index = current_index
all_active_with_start_date[index.succ] if index
end
|