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, Base::SOURCE_ERROR_MSG
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
59
60
61
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 59
def active?
state == 'active'
end
|
#all_active ⇒ Object
91
92
93
94
95
96
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 91
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
86
87
88
89
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 86
def all_active_with_start_date
@all_active_with_start_date ||=
all_active.select(&:start_date).sort_by(&:start_date)
end
|
#closed? ⇒ Boolean
63
64
65
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 63
def closed?
state == 'closed'
end
|
#current_index ⇒ Object
81
82
83
84
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 81
def current_index
all_active_with_start_date
.index { |milestone| milestone.id == id }
end
|
#expired?(today = Date.today) ⇒ Boolean
71
72
73
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 71
def expired?(today = Date.today)
due_date && due_date < today
end
|
#in_progress?(today = Date.today) ⇒ Boolean
75
76
77
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 75
def in_progress?(today = Date.today)
started?(today) && !expired?(today)
end
|
#started?(today = Date.today) ⇒ Boolean
67
68
69
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 67
def started?(today = Date.today)
start_date && start_date <= today
end
|
#succ ⇒ Object
53
54
55
56
57
|
# File 'lib/gitlab/triage/resource/milestone.rb', line 53
def succ
index = current_index
all_active_with_start_date[index.succ] if index
end
|