| 1 |
#!/usr/bin/ruby -w
|
| 2 |
|
| 3 |
require 'date'
|
| 4 |
require 'datafiles'
|
| 5 |
require 'html'
|
| 6 |
|
| 7 |
DATEZERO = Date::parse('0000-01-01')
|
| 8 |
CURDATE = Date::today
|
| 9 |
|
| 10 |
$testing = read_testing
|
| 11 |
$srcpkg, $pkgs = read_sources
|
| 12 |
$popcon = read_popcon
|
| 13 |
$rcbugs, $bugs = read_bugs
|
| 14 |
$wnpp = read_wnpp
|
| 15 |
$actions = Actions::read('package-actions.txt')
|
| 16 |
$orph = OrphanedPackage::readfile
|
| 17 |
$uploadhistory = LastUpload::readfile
|
| 18 |
|
| 19 |
# Compute score for all packages
|
| 20 |
$score = {}
|
| 21 |
$pkgs.keys.each do |pkg|
|
| 22 |
score = 0
|
| 23 |
if $testing[pkg]
|
| 24 |
ts = $testing[pkg]
|
| 25 |
score += ts.testingdays
|
| 26 |
score += (ts.syncdays * 0.5) if ts.syncdays > 10
|
| 27 |
else
|
| 28 |
score += 1000000
|
| 29 |
end
|
| 30 |
if $actions[pkg] and $actions[pkg].act_todo
|
| 31 |
score += 100000 # bump score if action needed
|
| 32 |
end
|
| 33 |
if $popcon[pkg] < 500
|
| 34 |
score += (500 - $popcon[pkg]) * 2
|
| 35 |
end
|
| 36 |
if $rcbugs[pkg] > 0
|
| 37 |
if $rcbugs[pkg] > 4
|
| 38 |
score += 5 * 300
|
| 39 |
else
|
| 40 |
score += $rcbugs[pkg] * 300
|
| 41 |
end
|
| 42 |
end
|
| 43 |
# score bugs
|
| 44 |
if $bugs[pkg] > 0
|
| 45 |
pc = $popcon[pkg]
|
| 46 |
bugs = $bugs[pkg]
|
| 47 |
if pc < 4000
|
| 48 |
norm = 1 + 0.002 * pc
|
| 49 |
elsif pc < 60000
|
| 50 |
norm = 7.85 + (16.0/56000) * pc
|
| 51 |
else
|
| 52 |
norm = 25
|
| 53 |
end
|
| 54 |
if bugs > norm
|
| 55 |
ret = (bugs - norm)/norm * 100 * 10 # 10 % en trop -> 100 pts
|
| 56 |
score += (ret > 2000 ? 2000 : ret)
|
| 57 |
end
|
| 58 |
end
|
| 59 |
$score[pkg] = score if score > 0
|
| 60 |
end
|
| 61 |
|
| 62 |
# Compute score, orphaned packages only
|
| 63 |
$oscore = {}
|
| 64 |
$pkgs.keys.each do |pkg|
|
| 65 |
next if !$orph.has_key?(pkg)
|
| 66 |
score = 0
|
| 67 |
score += (Time::now - $orph[pkg].date) / 86400 * 10
|
| 68 |
if $testing[pkg]
|
| 69 |
ts = $testing[pkg]
|
| 70 |
score += ts.testingdays
|
| 71 |
score += (ts.syncdays * 0.5) if ts.syncdays > 10
|
| 72 |
else
|
| 73 |
score += 1000000
|
| 74 |
end
|
| 75 |
if $actions[pkg] and $actions[pkg].act_todo
|
| 76 |
score += 100000 # bump score if action needed
|
| 77 |
end
|
| 78 |
if $popcon[pkg] < 500
|
| 79 |
score += (500 - $popcon[pkg]) * 2
|
| 80 |
end
|
| 81 |
if $rcbugs[pkg] > 0
|
| 82 |
if $rcbugs[pkg] > 4
|
| 83 |
score += 5 * 300
|
| 84 |
else
|
| 85 |
score += $rcbugs[pkg] * 300
|
| 86 |
end
|
| 87 |
end
|
| 88 |
# score bugs
|
| 89 |
if $bugs[pkg] > 0
|
| 90 |
pc = $popcon[pkg]
|
| 91 |
bugs = $bugs[pkg]
|
| 92 |
if pc < 4000
|
| 93 |
norm = 1 + 0.002 * pc
|
| 94 |
elsif pc < 60000
|
| 95 |
norm = 7.85 + (16.0/56000) * pc
|
| 96 |
else
|
| 97 |
norm = 25
|
| 98 |
end
|
| 99 |
if bugs > norm
|
| 100 |
ret = (bugs - norm)/norm * 100 * 10 # 10% more -> 100 pts
|
| 101 |
score += (ret > 2000 ? 2000 : ret)
|
| 102 |
end
|
| 103 |
end
|
| 104 |
$oscore[pkg] = score if score > 0
|
| 105 |
end
|
| 106 |
|
| 107 |
# Generate HTML files
|
| 108 |
f = File::new('scores.html', 'w')
|
| 109 |
gen_html($score, f)
|
| 110 |
f.close
|
| 111 |
f = File::new('scores_orphaned.html', 'w')
|
| 112 |
gen_html($oscore, f, true)
|
| 113 |
f.close
|