Class: ProjectHealth::PullRequestsReport
- Inherits:
-
Object
- Object
- ProjectHealth::PullRequestsReport
- Defined in:
- lib/project-health/report/pull_requests.rb
Instance Attribute Summary collapse
-
#all ⇒ Object
readonly
Returns the value of attribute all.
-
#closed ⇒ Object
readonly
Returns the value of attribute closed.
-
#open ⇒ Object
readonly
Returns the value of attribute open.
Instance Method Summary collapse
- #average_open_time ⇒ Object
- #closed_percent ⇒ Object
- #health ⇒ Object
-
#initialize(oct, name) ⇒ PullRequestsReport
constructor
A new instance of PullRequestsReport.
- #max_open_time ⇒ Object
- #min_open_time ⇒ Object
- #open_closed_ratio ⇒ Object
- #open_percent ⇒ Object
- #open_time ⇒ Object
- #stats ⇒ Object
Constructor Details
#initialize(oct, name) ⇒ PullRequestsReport
Returns a new instance of PullRequestsReport.
6 7 8 9 10 11 |
# File 'lib/project-health/report/pull_requests.rb', line 6 def initialize(oct, name) @open_times = [] @open = oct.pull_requests(name, :open).tap{|x| x.each(&method(:calc_open_pull_time)) }.count @closed = oct.pull_requests(name, :closed).count @all = open + closed end |
Instance Attribute Details
#all ⇒ Object (readonly)
Returns the value of attribute all.
4 5 6 |
# File 'lib/project-health/report/pull_requests.rb', line 4 def all @all end |
#closed ⇒ Object (readonly)
Returns the value of attribute closed.
4 5 6 |
# File 'lib/project-health/report/pull_requests.rb', line 4 def closed @closed end |
#open ⇒ Object (readonly)
Returns the value of attribute open.
4 5 6 |
# File 'lib/project-health/report/pull_requests.rb', line 4 def open @open end |
Instance Method Details
#average_open_time ⇒ Object
48 49 50 |
# File 'lib/project-health/report/pull_requests.rb', line 48 def average_open_time open_time / open if open > 0 end |
#closed_percent ⇒ Object
36 37 38 |
# File 'lib/project-health/report/pull_requests.rb', line 36 def closed_percent closed.percent_of all end |
#health ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/project-health/report/pull_requests.rb', line 60 def health case open_closed_ratio.to_f when 0..0.1 "Good" when 0.1..0.2 "Normal" when 0.2..1 "Bad" else "Unknown" end end |
#max_open_time ⇒ Object
56 57 58 |
# File 'lib/project-health/report/pull_requests.rb', line 56 def max_open_time @open_times.max end |
#min_open_time ⇒ Object
52 53 54 |
# File 'lib/project-health/report/pull_requests.rb', line 52 def min_open_time @open_times.min end |
#open_closed_ratio ⇒ Object
40 41 42 |
# File 'lib/project-health/report/pull_requests.rb', line 40 def open_closed_ratio result = open_percent / closed_percent end |
#open_percent ⇒ Object
32 33 34 |
# File 'lib/project-health/report/pull_requests.rb', line 32 def open_percent open.percent_of all end |
#open_time ⇒ Object
44 45 46 |
# File 'lib/project-health/report/pull_requests.rb', line 44 def open_time @open_times.inject(:+) || 0 end |
#stats ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/project-health/report/pull_requests.rb', line 13 def stats { "Pull Requests"=> { 'All' => all, 'Open' => open, 'Closed' => closed, 'Open %' => open_percent.to_f.round(2), 'Closed %' => closed_percent.to_f.round(2), 'Open/Closed % ratio' => open_closed_ratio.to_f.round(2), 'Open time in days' => open_time, 'Min open time in days' => min_open_time, 'Max open time in days' => max_open_time, 'Average days request is opened' => average_open_time, 'Health' => health } }.delete_if{|k,v| v.kind_of?(Float) && v.nan?} end |