embulk-input-jira 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: 14d965de93b1ed1a36384160c678009c61e87f12
4
- data.tar.gz: cc230ada4b25382dc40ce20912f9e87181e8ca72
3
+ metadata.gz: 7fb29dc47926d5c193b6b8b08f4a824cd2a83872
4
+ data.tar.gz: 2ebccda2aa31109d07021be6a1bdcdd052376f64
5
5
  SHA512:
6
- metadata.gz: 207f74f545d0d951ef5f8644f3557d3a60d6e1599e184eb88a6bcc6d491e38c55482350c6301e73651c8faf08dc572ad53f82dc82e53ada8fe683472fb81e491
7
- data.tar.gz: 9cd3d4d3b4ac8909945d6de6e67b24c309ddcf00a457410d9abc6f564bdacbf7153947fc79fd4f341808faa5876d25de6a1d745c4d7e57e2e34b6f4c9f3f0ed2
6
+ metadata.gz: fc399cfc63fd0adc78b46f4824a0ee12d45d0acfbb7dc249d43888c63b5e9c466a6ab08c5bdedcfcf9727448605084ff3646d0d31c4732f61723c002e18a22dc
7
+ data.tar.gz: 90475bce6b6d0572d51e52cea7c36345bc5c2a52b93c4dc7da488bd32eca991eb4745de7853a244930843b9d3f4034aecfb808e4633c57aa8ba36759cd36e64d
@@ -1,3 +1,7 @@
1
+ ## 0.0.6 - 2015-06-24
2
+ * [maintenance] String keys to symbols [#35](https://github.com/treasure-data/embulk-input-jira/pull/35)
3
+ * [enhancement] Faster fetching with parallel API request [#34](https://github.com/treasure-data/embulk-input-jira/pull/34)
4
+
1
5
  ## 0.0.5 - 2015-06-24
2
6
 
3
7
  **Embulk 0.6.12+ is required since this version**
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "embulk-input-jira"
3
- spec.version = "0.0.5"
3
+ spec.version = "0.0.6"
4
4
  spec.authors = ["uu59", "yoshihara"]
5
5
  spec.summary = "Jira input plugin for Embulk"
6
6
  spec.description = "Loads records from Jira."
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.require_paths = ["lib"]
14
14
 
15
15
  spec.add_dependency 'jiralicious', ['~> 0.5.0']
16
+ spec.add_dependency 'parallel', ['~> 1.6.0']
16
17
  spec.add_development_dependency 'bundler', ['~> 1.0']
17
18
  spec.add_development_dependency 'rake', ['>= 10.0']
18
19
  spec.add_development_dependency 'rspec', "~> 3.2.0"
@@ -12,21 +12,21 @@ module Embulk
12
12
 
13
13
  def self.transaction(config, &control)
14
14
  task = {
15
- "username" => config.param("username", :string),
16
- "password" => config.param("password", :string),
17
- "uri" => config.param("uri", :string),
18
- "jql" => config.param("jql", :string),
15
+ username: config.param(:username, :string),
16
+ password: config.param(:password, :string),
17
+ uri: config.param(:uri, :string),
18
+ jql: config.param(:jql, :string),
19
19
  }
20
20
 
21
21
  attributes = {}
22
- columns = config.param("columns", :array).map do |column|
22
+ columns = config.param(:columns, :array).map do |column|
23
23
  name = column["name"]
24
24
  type = column["type"].to_sym
25
25
  attributes[name] = type
26
26
  Column.new(nil, name, type, column["format"])
27
27
  end
28
28
 
29
- task["attributes"] = attributes
29
+ task[:attributes] = attributes
30
30
 
31
31
  resume(task, columns, 1, &control)
32
32
  end
@@ -39,22 +39,20 @@ module Embulk
39
39
  end
40
40
 
41
41
  def self.guess(config)
42
- # TODO: api_version should be 2 (the latest version)
43
- # auth_type should be specified from config. (The future task)
44
-
45
- username = config.param("username", :string)
46
- password = config.param("password", :string)
47
- uri = config.param("uri", :string)
48
- api_version = "latest"
49
- auth_type = "basic"
50
- jql = config.param("jql", :string)
42
+ username = config.param(:username, :string)
43
+ password = config.param(:password, :string)
44
+ uri = config.param(:uri, :string)
45
+ jql = config.param(:jql, :string)
51
46
 
52
47
  jira = JiraApi::Client.setup do |jira_config|
48
+ # TODO: api_version should be 2 (the latest version)
49
+ # auth_type should be specified from config. (The future task)
50
+
53
51
  jira_config.username = username
54
52
  jira_config.password = password
55
53
  jira_config.uri = uri
56
- jira_config.api_version = api_version
57
- jira_config.auth_type = auth_type
54
+ jira_config.api_version = "latest"
55
+ jira_config.auth_type = "basic"
58
56
  end
59
57
 
60
58
  # TODO: we use 0..10 issues to guess config?
@@ -72,15 +70,15 @@ module Embulk
72
70
  end
73
71
 
74
72
  def init
75
- @attributes = task["attributes"]
73
+ @attributes = task[:attributes]
76
74
  @jira = JiraApi::Client.setup do |config|
77
- config.username = task["username"]
78
- config.password = task["password"]
79
- config.uri = task["uri"]
75
+ config.username = task[:username]
76
+ config.password = task[:password]
77
+ config.uri = task[:uri]
80
78
  config.api_version = "latest"
81
- config.auth_type = :basic
79
+ config.auth_type = "basic"
82
80
  end
83
- @jql = task["jql"]
81
+ @jql = task[:jql]
84
82
  end
85
83
 
86
84
  def run
@@ -1,4 +1,5 @@
1
1
  require "jiralicious"
2
+ require "parallel"
2
3
  require "embulk/input/jira_api/issue"
3
4
  require "timeout"
4
5
 
@@ -6,6 +7,7 @@ module Embulk
6
7
  module Input
7
8
  module JiraApi
8
9
  class Client
10
+ PARALLEL_THREAD_COUNT = 50
9
11
  SEARCH_TIMEOUT_SECONDS = 5
10
12
  SEARCH_ISSUES_TIMEOUT_SECONDS = 60
11
13
  DEFAULT_SEARCH_RETRY_TIMES = 10
@@ -17,7 +19,10 @@ module Embulk
17
19
 
18
20
  def search_issues(jql, options={})
19
21
  timeout_and_retry(SEARCH_ISSUES_TIMEOUT_SECONDS) do
20
- search(jql, options).issues.map do |issue|
22
+ issues_raw = search(jql, options).issues_raw
23
+ Parallel.map(issues_raw, in_threads: PARALLEL_THREAD_COUNT) do |issue_raw|
24
+ # https://github.com/dorack/jiralicious/blob/v0.4.0/lib/jiralicious/search_result.rb#L32-34
25
+ issue = Jiralicious::Issue.find(issue_raw["key"])
21
26
  JiraApi::Issue.new(issue)
22
27
  end
23
28
  end
@@ -48,7 +48,7 @@ describe Embulk::Input::JiraApi::Client do
48
48
  "summary" => "issue summary",
49
49
  "project" =>
50
50
  {
51
- "key" => "FOO"
51
+ "key" => "FO1"
52
52
  }
53
53
  }
54
54
  },
@@ -60,7 +60,7 @@ describe Embulk::Input::JiraApi::Client do
60
60
  "summary" => "jira issue",
61
61
  "project" =>
62
62
  {
63
- "key" => "FOO"
63
+ "key" => "FO2"
64
64
  }
65
65
  }
66
66
  }
@@ -70,7 +70,8 @@ describe Embulk::Input::JiraApi::Client do
70
70
  subject { Embulk::Input::JiraApi::Client.new.search_issues(jql) }
71
71
 
72
72
  it do
73
- allow(Jiralicious).to receive_message_chain(:search, :issues).and_return(results)
73
+ allow(Jiralicious).to receive_message_chain(:search, :issues_raw).and_return(results)
74
+ allow(Jiralicious::Issue).to receive(:find).and_return(results.first)
74
75
 
75
76
  expect(subject).to be_kind_of Array
76
77
  expect(subject.map(&:class)).to match_array [Embulk::Input::JiraApi::Issue, Embulk::Input::JiraApi::Issue]
@@ -15,11 +15,11 @@ describe Embulk::Input::Jira do
15
15
 
16
16
  let(:task) do
17
17
  {
18
- "username" => username,
19
- "password" => password,
20
- "uri" => uri,
21
- "jql" => jql,
22
- "attributes" => {
18
+ username: username,
19
+ password: password,
20
+ uri: uri,
21
+ jql: jql,
22
+ attributes: {
23
23
  "project.key" => :string,
24
24
  "comment.total" => :long
25
25
  }
@@ -41,11 +41,11 @@ describe Embulk::Input::Jira do
41
41
  end
42
42
 
43
43
  before do
44
- allow(config).to receive(:param).with("username", :string).and_return(username)
45
- allow(config).to receive(:param).with("password", :string).and_return(password)
46
- allow(config).to receive(:param).with("uri", :string).and_return(uri)
47
- allow(config).to receive(:param).with("jql", :string).and_return(jql)
48
- allow(config).to receive(:param).with("columns", :array).and_return(columns)
44
+ allow(config).to receive(:param).with(:username, :string).and_return(username)
45
+ allow(config).to receive(:param).with(:password, :string).and_return(password)
46
+ allow(config).to receive(:param).with(:uri, :string).and_return(uri)
47
+ allow(config).to receive(:param).with(:jql, :string).and_return(jql)
48
+ allow(config).to receive(:param).with(:columns, :array).and_return(columns)
49
49
  end
50
50
 
51
51
  # NOTE: I should check other factor, but i don't know it...
@@ -60,11 +60,11 @@ describe Embulk::Input::Jira do
60
60
 
61
61
  let(:task) do
62
62
  {
63
- "username" => username,
64
- "password" => password,
65
- "uri" => uri,
66
- "jql" => jql,
67
- "attributes" => {
63
+ username: username,
64
+ password: password,
65
+ uri: uri,
66
+ jql: jql,
67
+ attributes: {
68
68
  "project.key" => :string,
69
69
  "comment.total" => :long
70
70
  }
@@ -129,10 +129,10 @@ describe Embulk::Input::Jira do
129
129
  before do
130
130
  allow(jira_api).to receive(:search_issues).with(jql, max_results: described_class::GUESS_RECORDS_COUNT).and_return(jira_issues)
131
131
 
132
- allow(config).to receive(:param).with("username", :string).and_return(username)
133
- allow(config).to receive(:param).with("password", :string).and_return(password)
134
- allow(config).to receive(:param).with("uri", :string).and_return(uri)
135
- allow(config).to receive(:param).with("jql", :string).and_return(jql)
132
+ allow(config).to receive(:param).with(:username, :string).and_return(username)
133
+ allow(config).to receive(:param).with(:password, :string).and_return(password)
134
+ allow(config).to receive(:param).with(:uri, :string).and_return(uri)
135
+ allow(config).to receive(:param).with(:jql, :string).and_return(jql)
136
136
  end
137
137
 
138
138
  it "setup Embulk::Input::JiraApi::Client" do
@@ -188,8 +188,8 @@ describe Embulk::Input::Jira do
188
188
  let(:page_builder) { Object.new } # add mock later
189
189
  let(:task) do
190
190
  {
191
- "jql" => jql,
192
- "attributes" => {"project.key" => "string"}
191
+ jql: jql,
192
+ attributes: {"project.key" => "string"}
193
193
  }
194
194
  end
195
195
 
@@ -243,8 +243,8 @@ describe Embulk::Input::Jira do
243
243
  let(:plugin) { described_class.new(task, nil, nil, page_builder) }
244
244
  let(:task) do
245
245
  {
246
- "jql" => jql,
247
- "attributes" => {"project.key" => "string"}
246
+ jql: jql,
247
+ attributes: {"project.key" => "string"}
248
248
  }
249
249
  end
250
250
  let(:page_builder) { double("page_builder") }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-jira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - uu59
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.5.0
28
+ - !ruby/object:Gem::Dependency
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.6.0
34
+ name: parallel
35
+ prerelease: false
36
+ type: :runtime
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: 1.6.0
28
42
  - !ruby/object:Gem::Dependency
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements: