lib/embulk/input/jira.rb in embulk-input-jira-0.0.1 vs lib/embulk/input/jira.rb in embulk-input-jira-0.0.2

- old
+ new

@@ -1,7 +1,9 @@ require "embulk/input/jira-input-plugin-utils" require "jira/api" +require "logger" +require "time" module Embulk module Input class JiraInputPlugin < InputPlugin PER_PAGE = 50 @@ -65,15 +67,10 @@ end columns = JiraInputPluginUtils.guess_columns(records) guessed_config = { - "username" => username, - "password" => password, - "uri" => uri, - "api_version" => api_version, - "auth_type" => auth_type, "columns" => columns, } return guessed_config end @@ -90,12 +87,14 @@ @jql = task["jql"] end def run total_count = @jira.total_count(@jql) + last_page = (total_count.to_f / PER_PAGE).ceil - 0.step(total_count, PER_PAGE) do |start_at| + 0.step(total_count, PER_PAGE).with_index(1) do |start_at, page| + logger.debug "Fetching #{page} / #{last_page} page" @jira.search_issues(@jql, start_at: start_at).each do |issue| values = @attributes.map do |(attribute_name, type)| JiraInputPluginUtils.cast(issue[attribute_name], type) end @@ -105,9 +104,24 @@ page_builder.finish commit_report = {} return commit_report + end + + def self.logger + @logger ||= + begin + logger = Logger.new($stdout) + logger.formatter = proc do |severity, datetime, progname, msg| + "#{datetime.strftime("%Y-%m-%d %H:%M:%S.%L %z")} [#{severity}] #{msg}\n" + end + logger + end + end + + def logger + self.class.logger end end end end