Class: JiraClient

Inherits:
Object
  • Object
show all
Defined in:
lib/integrations/jira_client.rb

Constant Summary collapse

ISSUES_CACHE_KEY =
"issues"
STORY_TYPE =
"Story"
BUG_TYPE =
"Bug"

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ JiraClient

Returns a new instance of JiraClient.



14
15
16
17
18
19
# File 'lib/integrations/jira_client.rb', line 14

def initialize(config)
  @client_config = config["client_config"]
  @issue_id_rgx = issue_id_rgx
  @cached_issues = load_cached_issues()
  @business_value_custom_field = "customfield_#{config["business_value_field_id"]}"
end

Instance Method Details

#merge_and_fetch_bugs!(commits) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/integrations/jira_client.rb', line 32

def merge_and_fetch_bugs!(commits)
  commits
    .reduce([]) do |acc, commit|
      issue_id = parse_id(commit.subject).to_sym
      issue = issue_id.present? ? find_by_id(issue_id) : nil
      if issue.present? && issue[:issue_type] == "Bug"
        bug = {}.merge(issue)
        bug[:bug_id] = bug.delete(:issue_id)
        commit.bug_id = bug[:bug_id]
        acc << bug
      end
      acc
    end
    .map { |bug| Store::Bug::index(bug) }
end

#merge_and_fetch_issues!(commits) ⇒ Object

TODO: Store Issues as they’re fetched.



22
23
24
25
26
27
28
29
30
# File 'lib/integrations/jira_client.rb', line 22

def merge_and_fetch_issues!(commits)
  issue_ids = fetch_issues(merge_issue_ids!(commits))
    .reject { |issue_id, issue| issue.empty? }
    .map { |issue_id, issue| Store::Issue::index(issue) }

  Store::Issue::cache(@cached_issues)

  issue_ids
end