Class: Dev::Jira::Issue

Inherits:
Object show all
Defined in:
lib/firespring_dev_commands/jira/issue.rb

Overview

Contains information and methods representing a Jira issue

Constant Summary collapse

NON_STORY_TYPES =

Issue subtypes which do not map to a story type

['epic', 'review', 'sub-task', 'code review sub-task', 'pre-deploy sub-task', 'deploy sub-task', 'devops sub-task'].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Issue

Returns a new instance of Issue.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/firespring_dev_commands/jira/issue.rb', line 11

def initialize(data)
  @data = data
  @project = Jira::Project.new(data)
  @parent = Jira::Parent.new(data) if data.respond_to?(:parent)
  @id = data.key
  @title = data.summary
  @points = calculate_points(data)
  @assignee = Jira::User.lookup(data.assignee&.accountId)
  @resolved_date = data.resolutiondate
  @histories = Jira::Histories.populate(data)
  @last_in_progress_history = nil
  @first_in_review_history = nil
  @last_closed_history = nil
end

Instance Attribute Details

#assigneeObject

Returns the value of attribute assignee.



8
9
10
# File 'lib/firespring_dev_commands/jira/issue.rb', line 8

def assignee
  @assignee
end

#dataObject

Returns the value of attribute data.



8
9
10
# File 'lib/firespring_dev_commands/jira/issue.rb', line 8

def data
  @data
end

#first_in_review_history=(value) ⇒ Object

Sets the attribute first_in_review_history

Parameters:

  • value

    the value to set the attribute first_in_review_history to.



8
9
10
# File 'lib/firespring_dev_commands/jira/issue.rb', line 8

def first_in_review_history=(value)
  @first_in_review_history = value
end

#historiesObject

Returns the value of attribute histories.



8
9
10
# File 'lib/firespring_dev_commands/jira/issue.rb', line 8

def histories
  @histories
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/firespring_dev_commands/jira/issue.rb', line 8

def id
  @id
end

#last_closed_history=(value) ⇒ Object

Sets the attribute last_closed_history

Parameters:

  • value

    the value to set the attribute last_closed_history to.



8
9
10
# File 'lib/firespring_dev_commands/jira/issue.rb', line 8

def last_closed_history=(value)
  @last_closed_history = value
end

#last_in_progress_history=(value) ⇒ Object

Sets the attribute last_in_progress_history

Parameters:

  • value

    the value to set the attribute last_in_progress_history to.



8
9
10
# File 'lib/firespring_dev_commands/jira/issue.rb', line 8

def last_in_progress_history=(value)
  @last_in_progress_history = value
end

#parentObject

Returns the value of attribute parent.



8
9
10
# File 'lib/firespring_dev_commands/jira/issue.rb', line 8

def parent
  @parent
end

#pointsObject

Returns the value of attribute points.



8
9
10
# File 'lib/firespring_dev_commands/jira/issue.rb', line 8

def points
  @points
end

#projectObject

Returns the value of attribute project.



8
9
10
# File 'lib/firespring_dev_commands/jira/issue.rb', line 8

def project
  @project
end

#resolved_dateObject

Returns the value of attribute resolved_date.



8
9
10
# File 'lib/firespring_dev_commands/jira/issue.rb', line 8

def resolved_date
  @resolved_date
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/firespring_dev_commands/jira/issue.rb', line 8

def title
  @title
end

Instance Method Details

#cycle_timeObject

Returns the cycle time of the issue (time between in progress and closed states)



27
28
29
30
# File 'lib/firespring_dev_commands/jira/issue.rb', line 27

def cycle_time
  # Calculate the difference and convert to days
  ((last_closed_history.created - last_in_progress_history.created) / 60 / 60 / 24).round(2)
end

#in_progress_cycle_timeObject

Returns the time the issue was in progress (time between in progress and in review states)



33
34
35
36
# File 'lib/firespring_dev_commands/jira/issue.rb', line 33

def in_progress_cycle_time
  # Calculate the difference and convert to days
  ((first_in_review_history.created - last_in_progress_history.created) / 60 / 60 / 24).round(2)
end

#in_review_cycle_timeObject

Returns the time the issue was in review (time between in review and closed states)



39
40
41
42
# File 'lib/firespring_dev_commands/jira/issue.rb', line 39

def in_review_cycle_time
  # Calculate the difference and convert to days
  ((last_closed_history.created - first_in_review_history.created) / 60 / 60 / 24).round(2)
end

#to_sObject

Converts the jira issue object to a string representation



97
98
99
# File 'lib/firespring_dev_commands/jira/issue.rb', line 97

def to_s
  "[#{id}] #{title} (#{points} pts) (resolved #{resolved_date}"
end