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

Contents of /udd/web/bugs.cgi

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.5