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

Contents of /udd/web/bugs.cgi

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.5