Class: Apadmi::Grout::FindTicketsToMoveJiraAction

Inherits:
FindTicketsToMoveAction show all
Defined in:
lib/apadmi/grout/actions/find_tickets_to_move_action/find_tickets_to_move_jira_action.rb

Overview

Finds and returns a list of all the issues that are ready to be moved Any tickets found that have the given status but *don't* appear ready to be moved will be flagged.

Instance Method Summary collapse

Constructor Details

#initialize(jira_board_service, git_utils, issues_from_chnglg, logger) ⇒ FindTicketsToMoveJiraAction

Returns a new instance of FindTicketsToMoveJiraAction.



21
22
23
24
25
26
# File 'lib/apadmi/grout/actions/find_tickets_to_move_action/find_tickets_to_move_jira_action.rb', line 21

def initialize(jira_board_service, git_utils, issues_from_chnglg, logger)
  @jira_board_service = jira_board_service
  @git_utils = git_utils
  @issues_from_changelog_action = issues_from_chnglg
  @logger = logger
end

Instance Method Details

#run(component, status, excluded_ticket_keys, custom_flag_messages = nil, options = nil) ⇒ Array<Apadmi::Grout::Issue>

Returns the issues ready to move.

Parameters:

  • component (String)

    Only include tickets tagged with this component

  • status (String)

    The status of tickets to be moved (Usually “Awaiting QA Release”)

  • excluded_ticket_keys (Array<String>)

    ticket keys to be excluded from consideration

  • custom_flag_messages (Apadmi::Grout::FlagMessages) (defaults to: nil)
  • options (Apadmi::Grout::JiraFindTicketsOptions) (defaults to: nil)

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/apadmi/grout/actions/find_tickets_to_move_action/find_tickets_to_move_jira_action.rb', line 34

def run(
  component,
  status,
  excluded_ticket_keys,
  custom_flag_messages = nil,
  options = nil
)
  custom_flag_messages ||= Apadmi::Grout::FlagMessages.default(status)
  options ||= Apadmi::Grout::JiraFindTicketsOptions.new(include_no_sprint_tickets: false)

  issues = @jira_board_service.search_unblocked_issues(
    component, status, [], options
  ).reject do |issue|
    excluded_ticket_keys.include? issue.key
  end

  issue_keys = issues.map(&:key)
  @logger.message("Found issues to consider #{issue_keys.join(", ")}")

  # Get the issues in the git changelog, filtered for the issues being considered
  changelog_ids = @issues_from_changelog_action.issue_ids_from_changelog(
    @git_utils.merge_changelog(issue_keys)
  )

  final_list = issues.filter do |issue|
    # Decide whether to include this ticket based on PRs
    status = process_prs(issue, custom_flag_messages)
    decide_should_include(issue, status, changelog_ids)
  end

  @logger.message("Final list:  #{final_list.map(&:key).join(", ")}")
  final_list
end