Class: DownloaderForDataCenter
- Inherits:
-
Downloader
- Object
- Downloader
- DownloaderForDataCenter
- Defined in:
- lib/jirametrics/downloader_for_data_center.rb
Constant Summary
Constants inherited from Downloader
Downloader::CURRENT_METADATA_VERSION
Instance Attribute Summary
Attributes inherited from Downloader
#board_id_to_filter_id, #file_system, #metadata, #start_date_in_query
Instance Method Summary collapse
- #bulk_fetch_issues(issue_datas:, board:, in_initial_query:) ⇒ Object
- #jira_instance_type ⇒ Object
- #search_for_issues(jql:, board_id:, path:) ⇒ Object
Methods inherited from Downloader
create, #delete_issues_from_cache_that_are_not_in_server, #download_board_configuration, #download_issues, #download_sprints, #download_statuses, #download_users, #file_prefix, #find_board_ids, #identify_other_issues_to_be_downloaded, #initialize, #last_modified, #load_metadata, #log, #make_jql, #metadata_pathname, #remove_old_files, #run, #save_metadata, #update_status_history_file
Constructor Details
This class inherits a constructor from Downloader
Instance Method Details
#bulk_fetch_issues(issue_datas:, board:, in_initial_query:) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/jirametrics/downloader_for_data_center.rb', line 43 def bulk_fetch_issues issue_datas:, board:, in_initial_query: log " Downloading #{issue_datas.size} issues", both: true payload = { 'expand' => [ 'changelog' ], 'fields' => ['*all'], 'issueIdsOrKeys' => issue_datas.collect(&:key) } response = @jira_gateway.post_request( relative_url: '/rest/api/2/issue/bulkfetch', payload: JSON.generate(payload) ) response['issues'].each do |issue_json| issue_json['exporter'] = { 'in_initial_query' => in_initial_query } issue = Issue.new(raw: issue_json, board: board) data = issue_datas.find { |d| d.key == issue.key } data.up_to_date = true data.last_modified = issue.updated data.issue = issue end issue_datas end |
#jira_instance_type ⇒ Object
4 5 6 |
# File 'lib/jirametrics/downloader_for_data_center.rb', line 4 def jira_instance_type 'Jira DataCenter' end |
#search_for_issues(jql:, board_id:, path:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/jirametrics/downloader_for_data_center.rb', line 8 def search_for_issues jql:, board_id:, path: log " JQL: #{jql}" escaped_jql = CGI.escape jql hash = {} max_results = 100 start_at = 0 total = 1 while start_at < total json = @jira_gateway.call_url relative_url: '/rest/api/2/search' \ "?jql=#{escaped_jql}&maxResults=#{max_results}&startAt=#{start_at}&fields=updated" json['issues'].each do |i| key = i['key'] cache_path = File.join(path, "#{key}-#{board_id}.json") last_modified = Time.parse(i['fields']['updated']) data = DownloadIssueData.new( key: key, last_modified: last_modified, found_in_primary_query: true, cache_path: cache_path, up_to_date: last_modified(filename: cache_path) == last_modified ) hash[key] = data end total = json['total'].to_i max_results = json['maxResults'] = " Found #{json['issues'].count} issues" log , both: true start_at += json['issues'].size end hash end |