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

Contents of /udd/web/bugs.cgi

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.5