bin/cobench in cobench-0.0.17 vs bin/cobench in cobench-0.0.18
- old
+ new
@@ -125,32 +125,35 @@
titles[d[:title]] = d[:title]
loog.info("The value of #{user}/#{d[:title]} is #{d[:total]}")
end
end
end
+ weights = {
+ 'HoC' => 1,
+ 'Pulls' => 200,
+ 'Issues' => 50,
+ 'Commits' => 5,
+ 'Reviews' => 75
+ }
data.each do |u, ms|
score = ms.map do |t, h|
- h[:total] * if t == 'HoC'
- 1
- elsif t == 'Pulls'
- 100
- elsif t == 'Issues'
- 50
- elsif t == 'Commits'
- 5
- elsif t == 'Reviews'
- 40
- else
- raise "Unknown title '#{t}'"
- end
+ raise "Unknown title '#{t}'" unless weights.key?(t)
+ h[:total] * weights[t]
end.inject(0, :+)
data[u]['Score'] = { total: score, href: '' }
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.each do |t|
xml.title t
+ end
+ end
+ xml.weights do
+ weights.each do |t, w|
+ xml.w(id: t) do
+ xml.text w
+ end
end
end
xml.coders do
data.each do |u, ms|
xml.coder(id: u, details: api.user(u).name) do