From 4ffb4937872835467509f433fd140d54320a6e10 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Mon, 25 May 2015 09:18:58 +0300 Subject: [PATCH] slice fetching --- .../generator/generator_fetcher.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/github_changelog_generator/generator/generator_fetcher.rb b/lib/github_changelog_generator/generator/generator_fetcher.rb index 5e65664..7cb3fd4 100644 --- a/lib/github_changelog_generator/generator/generator_fetcher.rb +++ b/lib/github_changelog_generator/generator/generator_fetcher.rb @@ -40,18 +40,15 @@ module GitHubChangelogGenerator def detect_actual_closed_dates(issues) print "Fetching closed dates for issues...\r" if @options[:verbose] - # TODO: implement async fetching with slice! - threads = [] - - issues.each do |issue| - threads << Thread.new do - find_closed_date_by_commit(issue) + max_thread_number = 50 + issues.each_slice(max_thread_number) do |issues_slice| + threads = [] + issues_slice.each do |issue| + threads << Thread.new { find_closed_date_by_commit(issue) } end + threads.each(&:join) + puts "Fetching closed dates for issues: Done!" if @options[:verbose] end - - threads.each(&:join) - - puts "Fetching closed dates for issues: Done!" if @options[:verbose] end # Fill :actual_date parameter of specified issue by closed date of the commit, if it was closed by commit.