Class: PredictabilityEngine::DataSources::Jira

Inherits:
Base
  • Object
show all
Defined in:
lib/predictability_engine/data_sources/jira.rb

Constant Summary collapse

IN_PROGRESS_KEYWORDS =
['In Progress', 'Doing', 'Active', 'Development', 'Progress'].freeze
FIELDS =
%w[summary issuetype created priority resolutiondate status].freeze

Instance Method Summary collapse

Methods inherited from Base

#configure, #load

Instance Method Details

#perform_load(spec) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/predictability_engine/data_sources/jira.rb', line 12

def perform_load(spec)
  @priority_aliases = yaml_priority_aliases(spec)

  if ENV['MOCK_JIRA'] == 'true'
    data = mock_data('JIRA_MOCK_DATA')
    # Even when mocked, we can validate the contract if requested
    data.each { |row| validate_issue_contract!(row) } if ENV['JIRA_CONTRACT_CHECK'] == 'true'
    return build_work_items(data)
  end

  profile, query, @workflow = resolve_source(spec)
  @jira_site = Config.jira(profile)[:site]
  client = build_client(profile)
  issues = fetch_issues(client, query)

  # Contract Validation
  issues.each { |issue| validate_issue_contract!(issue) } if ENV['JIRA_CONTRACT_CHECK'] == 'true'

  data = issues.map { |issue| map_issue(issue) }
  build_work_items(data)
end