/[collab-qa]/udd/web/bugs.cgi
ViewVC logotype

Contents of /udd/web/bugs.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1841 - (show annotations) (download)
Wed Nov 3 06:52:06 2010 UTC (3 years, 9 months ago) by lucas
File size: 15702 byte(s)
XSF bugs triaging
1 #!/usr/bin/ruby -w
2
3 require 'dbi'
4 require 'pp'
5 require 'cgi'
6
7 puts "Content-type: text/html\n\n"
8
9 RELEASE_RESTRICT = [
10 ['squeeze', 'squeeze', 'id in (select id from bugs_rt_affects_testing)'],
11 ['sid', 'sid', 'id in (select id from bugs_rt_affects_unstable)'],
12 ['squeeze_and_sid', 'squeeze and sid', 'id in (select id from bugs_rt_affects_testing) and id in (select id from bugs_rt_affects_unstable)'],
13 ['squeeze_or_sid', 'squeeze or sid', 'id in (select id from bugs_rt_affects_testing union select id from bugs_rt_affects_unstable)'],
14 ['squeeze_not_sid', 'squeeze, not sid', 'id in (select id from bugs_rt_affects_testing) and id not in (select id from bugs_rt_affects_unstable)'],
15 ['sid_not_squeeze', 'sid, not squeeze', 'id in (select id from bugs_rt_affects_unstable) and id not in (select id from bugs_rt_affects_testing)'],
16 ['lenny', 'lenny', 'id in (select id from bugs_rt_affects_stable)'],
17 ['any', 'any', 'id in (select id from bugs where status!=\'done\')'],
18 ]
19
20 FILTERS = [
21 ['patch', 'tagged patch', 'id in (select id from bugs_tags where tag=\'patch\')'],
22 ['pending', 'tagged pending', 'id in (select id from bugs_tags where tag=\'pending\')'],
23 ['security', 'tagged security', 'id in (select id from bugs_tags where tag=\'security\')'],
24 ['wontfix', 'tagged wontfix', 'id in (select id from bugs_tags where tag=\'wontfix\')'],
25 ['upstream', 'tagged upstream', 'id in (select id from bugs_tags where tag=\'upstream\')'],
26 ['forwarded', 'forwarded upstream', 'forwarded != \'\''],
27 ['claimed', 'claimed bugs', "id in (select id from bugs_usertags where email='bugsquash@qa.debian.org')"],
28 ['deferred', 'fixed in deferred/delayed', "id in (select id from deferred_closes)"],
29 ['notmain', 'packages not in main', 'id not in (select id from bugs_packages, sources where bugs_packages.source = sources.source and component=\'main\')'],
30 ['notsqueeze', 'packages not in squeeze', 'id not in (select id from bugs_packages, sources where bugs_packages.source = sources.source and release=\'squeeze\')'],
31 ['base', 'packages in base system', 'bugs.source in (select source from sources where priority=\'required\' or priority=\'important\')'],
32 ['standard', 'packages in standard installation', 'bugs.source in (select source from sources where priority=\'standard\')'],
33 ['merged', 'merged bugs', 'id in (select id from bugs_merged_with where id > merged_with)'],
34 ['done', 'marked as done', 'status = \'done\''],
35 ['outdatedsqueeze', 'outdated binaries in squeeze', "bugs.source in (select distinct p1.source from packages_summary p1, packages_summary p2 where p1.source = p2.source and p1.release='squeeze' and p2.release='squeeze' and p1.source_version != p2.source_version)"],
36 ['outdatedsid', 'outdated binaries in sid', "bugs.source in (select distinct p1.source from packages_summary p1, packages_summary p2 where p1.source = p2.source and p1.release='sid' and p2.release='sid' and p1.source_version != p2.source_version)"],
37 ['needmig', 'different versions in squeeze and sid', "bugs.source in (select s1.source from sources s1, sources s2 where s1.source = s2.source and s1.release = 'squeeze' and s2.release='sid' and s1.version != s2.version)"],
38 ['newerubuntu', 'newer in Ubuntu than in sid', "bugs.source in (select s1.source from sources_uniq s1, ubuntu_sources s2 where s1.source = s2.source and s1.release = 'sid' and s2.release='natty' and s1.version < s2.version)"],
39 ]
40
41 TYPES = [
42 ['rc', 'release-critical bugs', 'severity >= \'serious\'', true ],
43 ['ipv6', 'release goal: IPv6 support', 'id in (select id from bugs_tags where tag=\'ipv6\')', false ],
44 ['lfs', 'release goal: Large File Support', 'id in (select id from bugs_tags where tag=\'lfs\')', false ],
45 ['boot', 'release goal: boot performance (init.d dependencies)', 'id in (select id from bugs_usertags where email = \'initscripts-ng-devel@lists.alioth.debian.org\')', false],
46 ['oldgnome', 'release goal: remove obsolete GNOME libraries', 'id in (select id from bugs_usertags where email = \'pkg-gnome-maintainers@lists.alioth.debian.org\' and tag=\'oldlibs\')', false],
47 ['ruby', 'Ruby bugs', "bugs.source in (select source from sources where maintainer ~ 'ruby' or uploaders ~ 'ruby')\nOR bugs.package in (select source from packages where (package ~ 'ruby' or depends ~ 'ruby') and source != 'subversion')\nOR title ~ 'ruby'"],
48 ['l10n', 'Localisation bugs', 'id in (select id from bugs_tags where tag=\'l10n\')', false],
49 ['xsf', 'X Strike Force bugs', "bugs.source in (select source from sources where maintainer ~ 'debian-x@lists.debian.org')\n"],
50 ['allbugs', 'All bugs', 'true', false],
51 ]
52
53 SORTS = [
54 ['id', 'bug#'],
55 ['source', 'source package'],
56 ['package', 'binary package'],
57 ['last_modified', 'last modified'],
58 ['severity', 'severity'],
59 ['popcon', 'popularity contest'],
60 ]
61
62 COLUMNS = [
63 ['cpopcon', 'popularity contest'],
64 ['chints', 'release team hints'],
65 ['cseverity', 'severity'],
66 ['ctags', 'tags'],
67 ['cclaimed', 'claimed by'],
68 ['cdeferred', 'deferred/delayed'],
69 ]
70
71 cgi = CGI::new
72 # releases
73 if RELEASE_RESTRICT.map { |r| r[0] }.include?(cgi.params['release'][0])
74 release = cgi.params['release'][0]
75 else
76 release = 'squeeze'
77 end
78 # columns
79 cols = {}
80 COLUMNS.map { |r| r[0] }.each do |r|
81 if cgi.params[r][0]
82 cols[r] = true
83 else
84 cols[r] = false
85 end
86 end
87 # sorts
88 if SORTS.map { |r| r[0] }.include?(cgi.params['sortby'][0])
89 sortby = cgi.params['sortby'][0]
90 else
91 sortby = 'id'
92 end
93 if ['asc', 'desc'].include?(cgi.params['sorto'][0])
94 sorto = cgi.params['sorto'][0]
95 else
96 sorto = 'asc'
97 end
98 # hack to enable popcon column if sortby = popcon
99 cols['cpopcon'] = true if sortby == 'popcon'
100 cols['cseverity'] = true if sortby == 'severity'
101 # filters
102 filters = {}
103 FILTERS.map { |r| r[0] }.each do |e|
104 if ['', 'only', 'ign'].include?(cgi.params[e][0])
105 filters[e] = cgi.params[e][0]
106 else
107 filters[e] = (e == 'merged' ? 'ign' : '')
108 end
109 end
110 # filter: newer than X days
111 if ['', 'only', 'ign'].include?(cgi.params['fnewer'][0])
112 fnewer = cgi.params['fnewer'][0]
113 else
114 fnewer = ''
115 end
116 if cgi.params['fnewerval'][0] =~ /^[0-9]+$/
117 fnewerval = cgi.params['fnewerval'][0].to_i
118 else
119 fnewerval = 7
120 end
121 # types
122 types = {}
123 TYPES.each do |t|
124 if cgi.params == {}
125 types[t[0]] = t[3]
126 else
127 if cgi.params[t[0]][0] == '1'
128 types[t[0]] = true
129 else
130 types[t[0]] = false
131 end
132 end
133 end
134
135 puts <<-EOF
136 <html>
137 <head>
138 <style type="text/css">
139
140 body {
141 font-family : "DejaVu Sans", "Bitstream Vera Sans", sans-serif;"
142 }
143
144 table.buglist td, table.buglist th {
145 border: 1px solid gray;
146 padding-left: 3px;
147 padding-right: 3px;
148 }
149 table.buglist tr:hover {
150 background-color: #ccc;
151 }
152 table {
153 border-collapse: collapse;
154 }
155
156 div#body {
157 border-top: 2px solid #d70751;
158 }
159
160 div.footer {
161 padding: 0.3em 0;
162 background-color: #fff;
163 text-align: center;
164 border-top: 2px solid #d70751;
165 margin: 0 0 0 0;
166 border-bottom: 0;
167 font-size: 85%;
168 }
169 </style>
170 <title>Debian Bugs Search @ UDD</title>
171 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
172 </head>
173 <body>
174 <h1 style="margin-bottom : 5px"><img src="http://qa.debian.org/debian.png" alt="Debian logo" width="188" height="52" style="vertical-align : -13px; ">Bugs Search <span style="color :#c70036">@</span> UDD</h1>
175 <div id="body">
176
177 <form action="bugs.cgi" method="get">
178 <p><b>Bugs affecting:</b>
179 EOF
180
181 RELEASE_RESTRICT.each do |r|
182 checked = (release == r[0] ? 'CHECKED=\'1\'':'')
183 puts "<input type='radio' name='release' value='#{r[0]}' #{checked}/>#{r[1]}&nbsp;&nbsp;"
184 end
185 puts <<-EOF
186 <br/>(also uses release tags and xxx-ignore information)</p>
187 <table class="invisible"><tr><td>
188 <table class="buglist">
189 <tr><th colspan='4'>FILTERS</th></tr>
190 <tr><th>not considered</th><th>only</th><th>ignore</th><th>type</th></tr>
191 EOF
192 FILTERS.each do |r|
193 puts <<-EOF
194 <tr>
195 <td style='text-align: center;'><input type='radio' name='#{r[0]}' value='' #{filters[r[0]]==''?'CHECKED=\'1\'':''}/></td>
196 <td style='text-align: center;'><input type='radio' name='#{r[0]}' value='only' #{filters[r[0]]=='only'?'CHECKED=\'1\'':''}/></td>
197 <td style='text-align: center;'><input type='radio' name='#{r[0]}' value='ign' #{filters[r[0]]=='ign'?'CHECKED=\'1\'':''}/></td>
198 <td>#{r[1]}</td>
199 </tr>
200 EOF
201 end
202 # newer than
203 puts <<-EOF
204 <tr>
205 <td style='text-align: center;'><input type='radio' name='fnewer' value='' #{fnewer==''?'CHECKED=\'1\'':''}/></td>
206 <td style='text-align: center;'><input type='radio' name='fnewer' value='only' #{fnewer=='only'?'CHECKED=\'1\'':''}/></td>
207 <td style='text-align: center;'><input type='radio' name='fnewer' value='ign' #{fnewer=='ign'?'CHECKED=\'1\'':''}/></td>
208 <td>newer than <input type='text' size='3' name='fnewerval' value='#{fnewerval}'/> days</td>
209 </tr>
210 EOF
211 puts "</table></td><td style='padding-left: 20px'><table class='buglist'>"
212 puts "<tr><th colspan='2'>Bug types</th></tr>"
213 TYPES.each do |t|
214 checked = types[t[0]]?" checked='1'":""
215 puts "<tr><td><input type='checkbox' name='#{t[0]}' value='1'#{checked}/></td><td>#{t[1]}</td></tr>"
216 end
217 puts "</table></td></tr></table>"
218 puts "<p><b>Sort by:</b> "
219 SORTS.each do |r|
220 checked = (sortby == r[0] ? 'CHECKED=\'1\'':'')
221 puts "<input type='radio' name='sortby' value='#{r[0]}' #{checked}/>#{r[1]}&nbsp;&nbsp;"
222 end
223 puts "<b> -- </b>"
224 [['asc', 'increasing'],[ 'desc', 'decreasing']].each do |r|
225 checked = (sorto == r[0] ? 'CHECKED=\'1\'':'')
226 puts "<input type='radio' name='sorto' value='#{r[0]}' #{checked}/>#{r[1]}&nbsp;&nbsp;"
227 end
228 puts "<br/>\n<b>Additional information:</b> "
229 COLUMNS.each do |r|
230 checked = cols[r[0]] ? 'checked':''
231 puts "<input type='checkbox' name='#{r[0]}' value='1' #{checked}/>#{r[1]}&nbsp;&nbsp;"
232 end
233 puts <<-EOF
234 <br/>\n<input type='submit' value='Search'/></p>
235 </form>
236 EOF
237 if cgi.params != {}
238
239 # Generate and execute query
240 tstart = Time::now
241 dbh = DBI::connect('DBI:Pg:dbname=udd;port=5441;host=localhost', 'guest')
242 if cols['cpopcon']
243 q = "select id, bugs.package, bugs.source, severity, title, last_modified, coalesce(popcon_src.insts, 0) as popcon\nfrom bugs left join popcon_src on (bugs.source = popcon_src.source) \n"
244 else
245 q = "select id, bugs.package, bugs.source, severity, title, last_modified from bugs \n"
246 end
247 q += "where #{RELEASE_RESTRICT.select { |r| r[0] == release }[0][2]} \n"
248 FILTERS.each do |f|
249 if filters[f[0]] == 'only'
250 q += "and #{f[2]} \n"
251 elsif filters[f[0]] == 'ign'
252 q += "and not (#{f[2]}) \n"
253 end
254 end
255 if fnewer == 'only'
256 q += "and (current_timestamp - interval '#{fnewerval} days' <= arrival) \n"
257 elsif fnewer == 'ign'
258 q += "and (current_timestamp - interval '#{fnewerval} days' > arrival) \n"
259 end
260 q2 = TYPES.select { |t| types[t[0]] }.map { |t| t[2] }.join("\n OR ")
261 if q2 != ""
262 q += "AND (#{q2})\n"
263 else
264 puts "<p><b>Must select at least one bug type!</b></p>"
265 q += "AND FALSE\n"
266 end
267 q += "order by #{sortby} #{sorto}"
268 begin
269 sth = dbh.prepare(q)
270 sth.execute
271 rows = sth.fetch_all
272 rescue DBI::ProgrammingError => e
273 puts "<p>The query generated an error, please report it to lucas@debian.org: #{e.message}</p>"
274 puts "<pre>#{q}</pre>"
275 exit(0)
276 end
277
278 if cols['chints']
279 sthh = dbh.prepare("select distinct source, type, argument, version, file, comment from relevant_hints order by type")
280 sthh.execute
281 rowsh = sthh.fetch_all
282 hints = {}
283 rowsh.each do |r|
284 hints[r['source']] ||= []
285 hints[r['source']] << r
286 end
287 end
288
289 if cols['ctags']
290 ids = rows.map { |r| r['id'] }.join(',')
291 stht = dbh.prepare("select id, tag from bugs_tags where id in (#{ids})")
292 stht.execute
293 rowst = stht.fetch_all
294 tags = {}
295 rowst.each do |r|
296 tags[r['id']] ||= []
297 tags[r['id']] << r['tag']
298 end
299 end
300
301 if cols['cclaimed']
302 ids = rows.map { |r| r['id'] }.join(',')
303 stht = dbh.prepare("select id, tag from bugs_usertags where email='bugsquash@qa.debian.org' and id in (#{ids})")
304 stht.execute
305 rowst = stht.fetch_all
306 claimedbugs = {}
307 rowst.each do |r|
308 claimedbugs[r['id']] ||= []
309 claimedbugs[r['id']] << r['tag']
310 end
311 end
312
313 if cols['cdeferred']
314 ids = rows.map { |r| r['id'] }.join(',')
315 sthd = dbh.prepare("select id, deferred.source, deferred.version, extract (day from delayed_until) as du from deferred, deferred_closes where deferred.source = deferred_closes.source and deferred.version = deferred_closes.version and deferred_closes.id in (#{ids})")
316 sthd.execute
317 rowsd = sthd.fetch_all
318 deferredbugs = {}
319 rowsd.each do |r|
320 d = r['du'].to_i
321 deferredbugs[r['id']] = "#{r['version']} (#{d}&nbsp;day#{d==1?'':'s'})"
322 end
323 end
324
325 puts "<p><b>#{rows.length} bugs found.</b></p>"
326 puts '<table class="buglist">'
327 puts '<tr><th>bug#</th><th>package</th><th>title</th>'
328 puts '<th>popcon</th>' if cols['cpopcon']
329 puts '<th>severity</th>' if cols['cseverity']
330 puts '<th>hints</th>' if cols['chints']
331 puts '<th>claimed by</th>' if cols['cclaimed']
332 puts '<th>deferred</th>' if cols['cdeferred']
333 puts '<th>last&nbsp;modified</th></tr>'
334
335 def genhints(source, hints)
336 return '' if hints.nil?
337 s = ''
338 hints.each do |h|
339 v = h['version'] ? h['version'] + ' ' : ''
340 t = h['type'] == 'age-days' ? "age/#{h['argument']}" : h['type']
341 s += "<a href=\"http://release.debian.org/britney/hints/#{h['file']}\" title=\"#{v}#{h['file']} #{h['comment']}\">#{t}</a> "
342 end
343 s
344 end
345
346 # copied from /org/bugs.debian.org/etc/config
347 $TagsSingleLetter = {
348 'patch' => '+',
349 'wontfix' => '☹',
350 'moreinfo' => 'M',
351 'unreproducible' => 'R',
352 'security' => 'S',
353 'pending' => 'P',
354 'fixed' => 'F',
355 'help' => 'H',
356 'fixed-upstream' => 'U',
357 'upstream' => 'u',
358 # Added tags
359 'confirmed' => 'C',
360 'etch-ignore' => 'etc-i',
361 'lenny-ignore' => 'len-i',
362 'sarge-ignore' => 'sar-i',
363 'squeeze-ignore' => 'squ-i',
364 'woody' => 'wod',
365 'sarge' => 'sar',
366 'etch' => 'etc',
367 'lenny' => 'len',
368 'squeeze' => 'squ',
369 'sid' => 'sid',
370 'experimental' => 'exp',
371 'l10n' => 'l10n',
372 'd-i' => 'd-i',
373 'ipv6' => 'ipv6',
374 'lfs' => 'lfs',
375 'fixed-in-experimental' => 'fie',
376 }
377
378 def gentags(tags)
379 return '' if tags.nil?
380 tags.sort!
381 texttags = tags.map do |tag|
382 puts "unknowntag: #{tag}" if $TagsSingleLetter[tag].nil?
383 "<abbr title='#{tag}'>#{$TagsSingleLetter[tag]}</abbr>"
384 end
385 return '&nbsp;[' + texttags.join('|') + ']'
386 end
387
388 rows.each do |r|
389 print "<tr><td style='text-align: left;'><a href=\"http://bugs.debian.org/#{r['id']}\">##{r['id']}</a>"
390 puts "#{gentags(tags[r['id']])}" if cols['ctags']
391 puts "</td>"
392 puts "<td style='text-align: center;'>"
393 srcs = r['source'].split(/,\s*/)
394 bins = r['package'].split(/,\s*/)
395 puts (0...bins.length).map { |i| "<a href=\"http://packages.qa.debian.org/#{srcs[i]}\">#{bins[i]}</a>" }.join(', ')
396 puts "</td>"
397 puts "<td>#{CGI::escapeHTML(r['title'])}</td>"
398 puts "<td>#{r['popcon']}</td>" if cols['cpopcon']
399 puts "<td>#{r['severity']}</td>" if cols['cseverity']
400 puts "<td>#{genhints(r['source'], hints[r['source']])}</td>" if cols['chints']
401 puts "<td>#{claimedbugs[r['id']]}</td>" if cols['cclaimed']
402 puts "<td>#{deferredbugs[r['id']]}</td>" if cols['cdeferred']
403 puts "<td style='text-align: center;'>#{r['last_modified'].to_date}</td></tr>"
404 end
405
406 puts "</table>"
407 sth2 = dbh.prepare("select max(start_time) from timestamps where source = 'bugs' and command = 'run'")
408 sth2.execute ; r2 = sth2.fetch_all
409 puts "<p><b>Generated in #{Time::now - tstart} seconds. Last data update: #{r2[0][0]}"
410 puts " (%.1f hours ago)</b></p>" % ((Time::now - r2[0][0].to_time) / 3600)
411 puts "<pre>#{q}</pre>"
412 end # if cgi.params != {}
413 puts <<-EOF
414 </div>
415 <div class="footer">
416 <small>Suggestions / comments / patches to lucas@debian.org. <a href="http://svn.debian.org/wsvn/collab-qa/udd/web/bugs.cgi">source code</a>.</small>
417 </div>
418 </body>
419 </html>
420 EOF

Properties

Name Value
svn:executable *
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.5