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

Contents of /udd/web/bugs.cgi

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.5