27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/ghamma/cli/duration.rb', line 27
def call(owner:, repo:, workflow:, since: nil, output: nil)
workflow_statement = "Fetching the durations of all workflow runs of #{workflow}"
since_statment = "since #{since}" if since
puts [workflow_statement, since_statment].join(" ")
progressbar = TTY::ProgressBar.new("Fetching workflow runs [:bar] :current/:total ETA: :eta", total: nil)
durations = GithubApiClient.new(owner: owner, repo: repo, token: ENV["GH_TOKEN"])
.fetch_workflow_duration_history(workflow, since, progressbar)
progressbar.finish
puts "Generating output"
durations_output = CSV.generate do |csv|
csv << ["ID", "Date", "Duration"]
durations.each do |duration|
csv << duration
end
end
if output
File.write(output, durations_output)
else
puts
puts durations_output
puts
end
puts "Done"
end
|