firespring_dev_commands 2.1.3 → 2.1.4.pre.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44213627e63b15337ede6416bf7dc17e6f70188d71ca2f2a19b601e61b21ae0e
4
- data.tar.gz: 356826da99f48dcaa041afe7afa642fdb18f72b38536b2a46753fd0a336508fa
3
+ metadata.gz: 782f199b829c9205d5d6539b2e6be9d5daed015cf00e4dc4dd8743c53925b967
4
+ data.tar.gz: 960a71a68186fa19525cb8935ece0deb6ee398c0400913eff2a6cf39b9806635
5
5
  SHA512:
6
- metadata.gz: 60b6e69d0bd7625fd033e528322d8d61512abdc3d1cd0637d295eeba000a65e8d55808a89c44c093fb09d136c6cba62a9641db4d30e54e0e248197a25693ca5e
7
- data.tar.gz: 0b3f4c05a9d1900179e2bd8cc7322390243a990cf04ca48963508af32dc54e6f469dc4bb151af2ce4968a371fc2e387e554db80f4f23a79dc9deeff2ea78fafc
6
+ metadata.gz: a662422f7c487bce2824f657c86099508af9185b71bc95168cccd8ba854282d8a0d981c6a1f6adf0b570cfa7ae4b46c05d7f9276ba3fe201c8bee175529badd4
7
+ data.tar.gz: 0e4872ea27d593ca5e87ff92c044ddcf7e5d284f18d2fe5644ad9d7e380da95468202ee3f4697443464cef1e113587219daaf82ba287e95e18b7c578160c5de9
@@ -0,0 +1,13 @@
1
+ require 'pry'
2
+
3
+ module Dev
4
+ class Jira
5
+ class Histories
6
+ def self.populate(data)
7
+ return nil unless data.attrs.key?('changelog')
8
+
9
+ data.changelog['histories'].map { |it| Jira::History.new(it) }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ require 'date'
2
+
3
+ module Dev
4
+ class Jira
5
+ class History
6
+ attr_accessor :date, :id, :author, :created, :items
7
+
8
+ def initialize(data)
9
+ @data = data
10
+ @id = data['id']
11
+ @author = data['author']
12
+ @items = data['items']
13
+ @created = Time.parse(data['created'])
14
+ end
15
+ end
16
+ end
17
+ end
@@ -5,7 +5,7 @@ module Dev
5
5
  # Issue subtypes which do not map to a story type
6
6
  NON_STORY_TYPES = ['review', 'sub-task', 'code review sub-task', 'pre-deploy sub-task', 'deploy sub-task', 'devops sub-task'].freeze
7
7
 
8
- attr_accessor :data, :project, :id, :title, :points, :assignee, :resolved_date
8
+ attr_accessor :data, :project, :id, :title, :points, :assignee, :resolved_date, :histories, :in_progress_history, :in_review_history, :closed_history
9
9
 
10
10
  def initialize(data)
11
11
  @data = data
@@ -15,10 +15,71 @@ module Dev
15
15
  @points = calculate_points(data)
16
16
  @assignee = Jira::User.lookup(data.assignee&.accountId)
17
17
  @resolved_date = data.resolutiondate
18
+ @histories = Jira::Histories.populate(data)
19
+ @in_progress_history = nil
20
+ @in_review_history = nil
21
+ @closed_history = nil
22
+ end
23
+
24
+ def cycle_time
25
+ # Calculate the difference and convert to days
26
+ ((last_closed_history.created - first_in_progress_history.created) / 60 / 60 / 24).round(2)
27
+ end
28
+
29
+ def in_progress_cycle_time
30
+ # Calculate the difference and convert to days
31
+ ((first_in_review_history.created - first_in_progress_history.created) / 60 / 60 / 24).round(2)
32
+ end
33
+
34
+ def in_review_cycle_time
35
+ # Calculate the difference and convert to days
36
+ ((last_closed_history.created - first_in_review_history.created) / 60 / 60 / 24).round(2)
37
+ end
38
+
39
+ private def first_in_progress_history
40
+ raise 'you must expand the changelog field to calculate cycle time' if histories.nil?
41
+
42
+ # Find the first instance in the histoy where the status moved to "In Progress"
43
+ @in_progress_history ||= histories.select do |history|
44
+ history.items.find do |item|
45
+ item['fieldId'] == 'status' && item['toString'] == 'In Progress'
46
+ end
47
+ end.min_by(&:created)
48
+ raise 'unable to find "In Progress" history entry needed to calculate cycle time' unless @in_progress_history
49
+
50
+ @in_progress_history
51
+ end
52
+
53
+ private def first_in_review_history
54
+ raise 'you must expand the changelog field to calculate cycle time' if histories.nil?
55
+
56
+ # Find the first instance in the histoy where the status moved to "In Review"
57
+ @in_review_history ||= histories.select do |history|
58
+ history.items.find do |item|
59
+ item['fieldId'] == 'status' && item['toString'] == 'In Review'
60
+ end
61
+ end.min_by(&:created)
62
+ raise 'unable to find "In Review" history entry needed to calculate cycle time' unless @in_review_history
63
+
64
+ @in_review_history
65
+ end
66
+
67
+ private def last_closed_history
68
+ raise 'you must expand the changelog field to calculate cycle time' if histories.nil?
69
+
70
+ # Find the last instance in the histoy where the status moved to "Closed"
71
+ @closed_history ||= histories.select do |history|
72
+ history.items.find do |item|
73
+ item['fieldId'] == 'status' && item['toString'] == 'Closed'
74
+ end
75
+ end.max_by(&:created)
76
+ raise 'unable to find "Closed" history entry needed to calculate cycle time' unless @closed_history
77
+
78
+ @closed_history
18
79
  end
19
80
 
20
81
  # Returns the value of the jira points field or 0 if the field is not found
21
- def calculate_points(data)
82
+ private def calculate_points(data)
22
83
  return data.send(Dev::Jira.config.points_field_name).to_i if Dev::Jira.config.points_field_name && data.respond_to?(Dev::Jira.config.points_field_name)
23
84
 
24
85
  0
@@ -9,15 +9,16 @@ module Dev
9
9
  # "user_lookup_list" should be an array of Jira::User objects representing the usernames, ids, etc for all jira users
10
10
  # This is a bit clumsy but currently the jira api only returns the user id with issues
11
11
  # and there is no way to query this information from Jira directly.
12
- Config = Struct.new(:username, :token, :url, :points_field_name, :user_lookup_list, :read_timeout, :http_debug) do
12
+ Config = Struct.new(:username, :token, :url, :points_field_name, :expand, :user_lookup_list, :read_timeout, :http_debug) do
13
13
  def initialize
14
14
  self.username = nil
15
15
  self.token = nil
16
16
  self.url = nil
17
17
  self.points_field_name = nil
18
+ self.expand = []
18
19
  self.user_lookup_list = []
19
20
  self.read_timeout = 120
20
- self.http_debug = false
21
+ self.http_debug = true
21
22
  end
22
23
  end
23
24
 
@@ -62,15 +63,16 @@ module Dev
62
63
  def issues(jql, &)
63
64
  start_at = 0
64
65
  max_results = 100
66
+ expand = self.class.config.expand
65
67
 
66
68
  # Query Jira and yield all issues it returns
67
- issues = @client.Issue.jql(jql, start_at:, max_results:)
69
+ issues = @client.Issue.jql(jql, start_at:, max_results:, expand:)
68
70
  issues.map { |data| Issue.new(data) }.each(&)
69
71
 
70
72
  # If we returned the max_results then there may be more - add the max results to where we start at and query again
71
73
  while issues.length >= max_results
72
74
  start_at += max_results
73
- issues = @client.Issue.jql(jql, start_at:, max_results:)
75
+ issues = @client.Issue.jql(jql, start_at:, max_results:, expand:)
74
76
  issues.map { |data| Issue.new(data) }.each(&)
75
77
  end
76
78
  end
@@ -6,11 +6,14 @@ module Dev
6
6
  class Application
7
7
  # Contains rake tasks for displaying and setting application variables in parameter store
8
8
  class Config < Dev::Template::ApplicationInterface
9
- attr_reader :path
9
+ attr_reader :path_prefix, :key_parameter_path
10
+
11
+ # Allow for custom config path_prefix for the application
12
+ # Allow for custom key parameter path (otherwise base it off the path prefix)
13
+ def initialize(name, path_prefix, key_parameter_path: nil, exclude: [])
14
+ @path_prefix = path_prefix
15
+ @key_parameter_path = key_parameter_path || "#{path_prefix}/kms/id"
10
16
 
11
- # Allow for custom config path for the application
12
- def initialize(name, path, exclude: [])
13
- @path = path
14
17
  super(name, exclude:)
15
18
  end
16
19
 
@@ -18,7 +21,7 @@ module Dev
18
21
  def create_list_task!
19
22
  # Have to set a local variable to be accessible inside of the instance_eval block
20
23
  application = @name
21
- path = @path
24
+ path_prefix = @path_prefix
22
25
  exclude = @exclude
23
26
 
24
27
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
@@ -29,8 +32,10 @@ module Dev
29
32
  desc "List all #{application} configs"
30
33
  task list: %w(init) do
31
34
  puts
32
- Dev::Aws::Parameter.new.list(path).each do |it|
33
- puts " #{it.name} => #{it.value} (#{it.type})"
35
+ puts "Listing all parameters which start with #{path_prefix}:".light_green
36
+ puts
37
+ Dev::Aws::Parameter.new.list(path_prefix).each do |it|
38
+ puts " #{it.name.light_white} => #{it.value.light_white} (#{it.type})"
34
39
  end
35
40
  puts
36
41
  end
@@ -44,7 +49,8 @@ module Dev
44
49
  def create_set_task!
45
50
  # Have to set a local variable to be accessible inside of the instance_eval block
46
51
  application = @name
47
- path = @path
52
+ path_prefix = @path_prefix
53
+ key_parameter_path = @key_parameter_path
48
54
  exclude = @exclude
49
55
 
50
56
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
@@ -58,7 +64,7 @@ module Dev
58
64
  "\n\toptionally specify ENCRYPT=true to change a String type to a SecureString type"
59
65
  task set: %w(ensure_aws_credentials) do
60
66
  raise 'NAME is required' if ENV['NAME'].to_s.strip.blank?
61
- raise 'NAME is not found in this apps parameters' if Dev::Aws::Parameter.new.list(path).none? { |it| it.name == ENV['NAME'] }
67
+ raise 'NAME is not found in this apps parameters' if Dev::Aws::Parameter.new.list(path_prefix).none? { |it| it.name == ENV['NAME'] }
62
68
  raise 'VALUE is required' if ENV['VALUE'].to_s.strip.blank?
63
69
 
64
70
  param_path = ENV.fetch('NAME', nil)
@@ -68,7 +74,7 @@ module Dev
68
74
  params = {type: 'String'}
69
75
  if ENV['ENCRYPT'].to_s.strip == 'true' || old_value.type == 'SecureString'
70
76
  params[:type] = 'SecureString'
71
- params[:key_id] = Dev::Aws::Parameter.new.get_value("#{path}/kms/id")
77
+ params[:key_id] = Dev::Aws::Parameter.new.get_value(key_parameter_path)
72
78
  end
73
79
 
74
80
  message = 'This will change '.light_green +
@@ -6,6 +6,6 @@ module Dev
6
6
  # Use 'v.v.v.pre.alpha.v' for pre-release vesions
7
7
  # Use 'v.v.v.beta.v for beta versions
8
8
  # Use semantic versioning for any releases (https://semver.org/)
9
- VERSION = '2.1.3'.freeze
9
+ VERSION = '2.1.4.pre.alpha.1'.freeze
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firespring_dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4.pre.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-22 00:00:00.000000000 Z
11
+ date: 2023-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -284,6 +284,8 @@ files:
284
284
  - lib/firespring_dev_commands/git.rb
285
285
  - lib/firespring_dev_commands/git/info.rb
286
286
  - lib/firespring_dev_commands/jira.rb
287
+ - lib/firespring_dev_commands/jira/histories.rb
288
+ - lib/firespring_dev_commands/jira/history.rb
287
289
  - lib/firespring_dev_commands/jira/issue.rb
288
290
  - lib/firespring_dev_commands/jira/project.rb
289
291
  - lib/firespring_dev_commands/jira/user.rb
@@ -331,9 +333,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
331
333
  version: '3.1'
332
334
  required_rubygems_version: !ruby/object:Gem::Requirement
333
335
  requirements:
334
- - - ">="
336
+ - - ">"
335
337
  - !ruby/object:Gem::Version
336
- version: '0'
338
+ version: 1.3.1
337
339
  requirements: []
338
340
  rubygems_version: 3.4.10
339
341
  signing_key: