Class: GhDraftIssueConverter::Converter
- Inherits:
-
Object
- Object
- GhDraftIssueConverter::Converter
- Defined in:
- lib/gh_draft_issues_converter/gh_draft_issues_converter.rb
Instance Method Summary collapse
-
#initialize(github_key) ⇒ Converter
constructor
A new instance of Converter.
- #run(project_number, repository, interval = 25) ⇒ Object
Constructor Details
#initialize(github_key) ⇒ Converter
Returns a new instance of Converter.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/gh_draft_issues_converter/gh_draft_issues_converter.rb', line 306 def initialize(github_key) client = Graphlient::Client.new( 'https://api.github.com/graphql', headers: { 'Authorization' => "Bearer #{github_key}" }, http_options: { read_timeout: 20, write_timeout: 30 } ) @resource_manager = GhResoucesManager.new(client) end |
Instance Method Details
#run(project_number, repository, interval = 25) ⇒ Object
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/gh_draft_issues_converter/gh_draft_issues_converter.rb', line 323 def run(project_number, repository, interval = 25) repository_id = @resource_manager.fetch_repository_id(repository) project_id = @resource_manager.fetch_project_id(project_number, repository) draft_issues = @resource_manager.fetch_draft_issues(project_id) draft_issues.select! do |draft_issue| !draft_issue.unnecessary_for_convert_issue? end if draft_issues.length.zero? puts "Nothing to convert items." exit end draft_issues.each_with_index do |draft_issue, index| puts "Converting: #{draft_issue.title}" issue_repository_id = @resource_manager.create_issue_from_draft( draft_issue, repository_id, project_id ) puts "Add ProjectV2..." issue_projectv2_id = @resource_manager.add_issue_projectv2(project_id, issue_repository_id) puts "Update Field Values..." @resource_manager.update_item_field_values(project_id, draft_issue, issue_projectv2_id) puts "Delete DraftIssue..." @resource_manager.delete_draft_issue(project_id, draft_issue) puts "Complete Convert." if index == draft_issues.length - 1 puts "All DraftIssue Converted." else # https://github.com/cli/cli/issues/4801#issuecomment-1431812916 puts "Sleep(25s) for rate limit..." sleep interval end end end |