Sha256: 1f15b86314af1a7c76a788a3b915ee1ce24e0bc455fd224fb4d0ae202016cb2c

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require 'jira-ruby'
require 'roko/source/base/report_events'

require_relative 'event_adapter'

module Roko
  module Source
    module Jira
      # report events from Jira
      class ReportEvents < Roko::Source::Base::ReportEvents
        def client
          options = {
            username: ENV['JIRA_USER'],
            password: ENV['JIRA_PASSWORD'],
            site: ENV['JIRA_URL'],
            context_path: ENV['JIRA_CONTEXT_PATH'],
            auth_type: :basic,
            rest_base_path: '/rest/api/2'
          }
          JIRA::Client.new(options)
        end

        # @param client [JIRA::Client]
        def fetch_service_event(client)
          jql = jql_status_changed_between(@start, @end)
          client.Issue.jql(jql)
        end

        # @param start_time [Time]
        # @param end_time [Time]
        def jql_status_changed_between(start_time, end_time)
          start_date = start_time.strftime('%Y/%m/%d')
          end_date = end_time.strftime('%Y/%m/%d')
          'status changed by currentUser()' \
            " AND updatedDate >= \"#{start_date}\"" \
            " AND updatedDate < \"#{end_date}\""
        end

        # @param event [JIRA::Resource::Issue]
        def to_report_event(event)
          EventAdapter.to_report_event(event)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roko-0.2.1 lib/roko/source/jira/report_events.rb
roko-0.2.0 lib/roko/source/jira/report_events.rb