-
Notifications
You must be signed in to change notification settings - Fork 28
/
graph.rb
108 lines (81 loc) · 2.65 KB
/
graph.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# frozen_string_literal: true
require 'gruff'
require 'csv'
require 'optparse'
def generate_pr_work_done_graph
data_set = CSV.read('pr_work_done.csv', headers: true)
graph = Gruff::Bar.new(800)
graph.title = 'Supported modules PR work done'
x_axis = []
data_set.each { |row| x_axis << row['week ending on'] }
count = 0
data_set.each do |iter|
graph.labels[count] = iter['week ending on'][5..-1]
count += 1
end
graph.label_stagger_height = 10
graph.data("PR's closed", data_set.collect { |x| x['closed'].to_i })
graph.data("PR's commented", data_set.collect { |x| x['commented'].to_i })
graph.data("PR's merged", data_set.collect { |x| x['merged'].to_i })
graph.x_axis_label = 'Week ending'
graph.y_axis_label = 'PRs'
graph.write('pr_work_done.png')
end
def prs_created_per_day_graph
data_set = CSV.read('created_per_day.csv', headers: true)
graph = Gruff::Bar.new(800)
graph.title = 'PRs Created Per Day'
x_axis = []
data_set.each { |row| x_axis << row['date'] }
count = 0
data_set.each do |iter|
graph.labels[count] = iter['date'][8..-1]
count += 1
end
graph.label_stagger_height = 10
graph.data('Puppet PRs', data_set.collect { |x| x['puppet'].to_i })
graph.data('Community PRs', data_set.collect { |x| x['community'].to_i })
graph.x_axis_label = 'Day (Last 20, ascending)'
graph.y_axis_label = 'PRs'
graph.write('prs_created_per_day.png')
end
def prs_currently_open_per_day_graph
data_set = CSV.read('daily_open_prs.csv', headers: true)
graph = Gruff::Area.new
graph.title = 'PRs Currently Open'
count = 0
data_set.each do |iter|
graph.labels[count] = iter['date'][8..-1]
count += 1
end
graph.label_stagger_height = 10
graph.data('Community PRs', data_set.collect { |x| x['community'].to_i })
graph.data('Puppet PRs', data_set.collect { |x| x['puppet'].to_i })
graph.data('Total PRs', data_set.collect { |x| x['total'].to_i })
graph.minimum_value = 0
graph.x_axis_label = 'Day (Last 20, ascending)'
graph.y_axis_label = 'PRs'
graph.write('daily_open_prs.png')
end
option_selected = 0
parser = OptionParser.new do |opts|
opts.banner = 'Usage: graph.rb [options]'
opts.on('--pr_work_done', 'Generate PR work done') do
generate_pr_work_done_graph
option_selected
end
opts.on('--created_prs_per_day', 'Generate PRs raised per day') do
prs_created_per_day_graph
option_selected += 1
end
opts.on('--open_prs_per_day', 'Generate PRs currently open per day') do
prs_currently_open_per_day_graph
option_selected += 1
end
end
parser.parse!
if option_selected.zero?
puts 'Missing options, please pick at least one'
puts parser
exit
end