Skip to content

Instantly share code, notes, and snippets.

@c80609a
Created October 31, 2018 11:15
Show Gist options
  • Save c80609a/ba8e692d2928cdeeac1b5eed0b3c1257 to your computer and use it in GitHub Desktop.
Save c80609a/ba8e692d2928cdeeac1b5eed0b3c1257 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
require 'csv'
require 'time'
headers = { 'PRIVATE-TOKEN' => ENV['GL_TOKEN'] }
issues = Enumerator.new do |result|
page = 1
data = open("https://gitlab.key-g.com/api/v4/issues?state=closed&scope=all&project_id=google-autocomplete-proxy&per_page=10&page=#{page}", headers).read
_issues = JSON.load(data)
while _issues.any?
_issues.each { |i| result << i }
page += 1
data = open("https://gitlab.key-g.com/api/v4/issues?state=closed&scope=all&project_id=google-autocomplete-proxy&per_page=10&page=#{page}", headers)
_issues = JSON.load(data)
end
end
CSV(File.new('./issues.csv', 'wb+')) do |csv|
csv << ["title", "assignee.name", "closed_at", 'created_at', 'url']
june = Time.parse('2018-07-01 00:00:00 +0300')
issues
.to_a
.each { |data| puts data.inspect }
.each { |data|
s = [
data['title'],
data['assignees'].map{ |ii| ii['name'] }.join(','),
data['created_at'],
(data['closed_at'] ? data['closed_at'] : data['updated_at']),
data['web_url']
]
csv << s
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment