Make it works async and fast!

This commit is contained in:
Petr Korolev 2015-02-17 23:21:19 +02:00
parent 0eacd9acda
commit 04f1173616

View File

@ -51,16 +51,28 @@ module GitHubChangelogGenerator
end end
def detect_actual_closed_dates def detect_actual_closed_dates
@issues.each{|issue|
closed_date = find_closed_date_by_commit(issue)
if @options[:verbose]
print "Fetching close commit date for issues...\r"
end
threads = []
@issues.each{|issue|
threads << Thread.new {
find_closed_date_by_commit(issue)
} }
}
threads.each { |thr| thr.join }
if @options[:verbose]
puts 'Fetching close commit date for issues: Done!'
end
return 0
end end
def find_closed_date_by_commit(issue) def find_closed_date_by_commit(issue)
closed_date = nil
puts issue[:number]
unless issue['events'].nil? unless issue['events'].nil?
# reverse! - to find latest closed event. (event goes in date order) # reverse! - to find latest closed event. (event goes in date order)
issue['events'].reverse!.each{|event| issue['events'].reverse!.each{|event|
@ -71,12 +83,10 @@ module GitHubChangelogGenerator
commit = @github.git_data.commits.get @options[:user], @options[:project], event[:commit_id] commit = @github.git_data.commits.get @options[:user], @options[:project], event[:commit_id]
issue[:actual_date] = commit[:author][:date] issue[:actual_date] = commit[:author][:date]
end end
break break
end end
} }
end end
closed_date
end end
def print_json(json) def print_json(json)