Created
October 9, 2017 09:23
-
-
Save tooooolong/b7769eae967306f4d27963ba2f4867a2 to your computer and use it in GitHub Desktop.
export gitlab ce issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest-client' | |
require 'json' | |
require 'time' | |
API_ENTRYPOINT = "YOUR_GITLAB_API_ADDRESS" | |
API_TOKEN = "YOUR_TOKEN" | |
def export_project(all_issues, project_id) | |
page = 1 | |
per_page = 50 | |
flag = true | |
while flag do | |
res = RestClient.get("#{API_ENTRYPOINT}/projects/#{project_id}/issues", { | |
params: { | |
state: 'closed', | |
page: page, | |
per_page: per_page, | |
order_by: "updated_at" | |
}, | |
"PRIVATE-TOKEN": API_TOKEN | |
}) | |
issues = JSON.parse(res.body) | |
flag = issues.size == per_page | |
page += 1 | |
issues.each do |issue| | |
t = Time.parse(issue['updated_at']).strftime("%Y-%m-%d") | |
all_issues[t] ||= [] | |
all_issues[t].push(issue) | |
end | |
end | |
end | |
all_issues = {} | |
export_project(all_issues, 1) | |
all_issues.each do |k, v| | |
puts k | |
v.each do |i| | |
puts(i['title']) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment