bin/cobench in cobench-0.0.23 vs bin/cobench in cobench-0.0.24
- old
+ new
@@ -119,11 +119,11 @@
loog.info("The value of #{user}/#{d[:title]} is #{d[:total]}")
end
end
end
caps = {
- 'HoC' => lambda { |ms| ms['Commits'][:total] * 512 },
+ 'HoC' => lambda { |ms| ms['Pulls'][:total] * 1024 },
}
data.each do |u, ms|
ms.map do |t, h|
next unless caps.key?(t)
cap = caps[t].call(ms)
@@ -146,20 +146,56 @@
raise "Unknown title '#{t}'" unless weights.key?(t)
h[:total] * weights[t]
end.inject(0, :+)
data[u]['Score'] = { total: score }
end
+ averages = {
+ 'HpP': {
+ f: lambda { |ms| ms['HoC'][:total] / ms['Pulls'][:total] },
+ title: 'HoC per Pull'
+ },
+ 'HpC': {
+ f: lambda { |ms| ms['HoC'][:total] / ms['Commits'][:total] },
+ title: 'HoC per Commit'
+ }
+ }
+ data.each do |u, ms|
+ averages.each do |k, a|
+ data[u][k] = { total: a[:f].call(ms) }
+ end
+ end
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
xml.cobench(time: Time.now, days: opts[:days]) do
xml.titles do
data.map { |_, ms| ms.keys }.flatten.uniq.each do |t|
- xml.title t
+ xml.title do
+ xml.parent.set_attribute('subtitle', averages[t][:title]) if averages.key?(t)
+ xml.text t
+ end
end
end
xml.weights do
weights.each do |t, w|
xml.w(id: t) do
- xml.text w
+ xml.text(w)
+ end
+ end
+ end
+ xml.totals do
+ data.map { |_, ms| ms.keys }.flatten.uniq.each do |t|
+ next if t == 'Score'
+ next if averages.key?(t)
+ xml.w(id: t) do
+ xml.text(data.values.map { |ms| ms[t][:total] }.inject(&:+))
+ end
+ end
+ end
+ xml.averages do
+ data.map { |_, ms| ms.keys }.flatten.uniq.each do |t|
+ next if t == 'Score'
+ xml.w(id: t) do
+ vals = data.values.map { |ms| ms[t][:total] }.select { |v| v > 0 }
+ xml.text(vals.inject(&:+) / vals.count)
end
end
end
xml.coders do
data.each do |u, ms|