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

Contents of /udd/web/bugs.cgi

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.5