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

Contents of /udd/web/bugs.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1794 - (show annotations) (download)
Wed Sep 15 20:03:08 2010 UTC (2 years, 8 months ago) by lucas
File size: 13240 byte(s)
support sorting by popcon
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 ]
18
19 FILTERS = [
20 ['patch', 'tagged patch', 'id in (select id from bugs_tags where tag=\'patch\')'],
21 ['pending', 'tagged pending', 'id in (select id from bugs_tags where tag=\'pending\')'],
22 ['security', 'tagged security', 'id in (select id from bugs_tags where tag=\'security\')'],
23 ['notmain', 'packages not in main', 'id not in (select id from bugs_packages, sources where bugs_packages.source = sources.source and component=\'main\')'],
24 ['notsqueeze', 'packages not in squeeze', 'id not in (select id from bugs_packages, sources where bugs_packages.source = sources.source and release=\'squeeze\')'],
25 ['merged', 'merged bugs', 'id in (select id from bugs_merged_with where id > merged_with)'],
26 ['done', 'marked as done', 'status = \'done\''],
27 ['outdatedsqueeze', 'outdated binaries in squeeze', "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)"],
28 ['outdatedsid', 'outdated binaries in sid', "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)"],
29 ]
30
31 TYPES = [
32 ['rc', 'release-critical bugs', 'severity >= \'serious\'', true ],
33 ['ipv6', 'release goal: IPv6 support', 'id in (select id from bugs_tags where tag=\'ipv6\')', false ],
34 ['lfs', 'release goal: Large File Support', 'id in (select id from bugs_tags where tag=\'lfs\')', false ],
35 ['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],
36 ['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],
37 ]
38
39 SORTS = [
40 ['id', 'bug#'],
41 ['source', 'source package'],
42 ['package', 'binary package'],
43 ['last_modified', 'last modified'],
44 ['popcon', 'popularity contest'],
45 ]
46
47 cgi = CGI::new
48 # releases
49 if RELEASE_RESTRICT.map { |r| r[0] }.include?(cgi.params['release'][0])
50 release = cgi.params['release'][0]
51 else
52 release = 'squeeze'
53 end
54 # sorts
55 if SORTS.map { |r| r[0] }.include?(cgi.params['sortby'][0])
56 sortby = cgi.params['sortby'][0]
57 else
58 sortby = 'id'
59 end
60 if ['asc', 'desc'].include?(cgi.params['sorto'][0])
61 sorto = cgi.params['sorto'][0]
62 else
63 sorto = 'asc'
64 end
65 # filters
66 filters = {}
67 FILTERS.map { |r| r[0] }.each do |e|
68 if ['', 'only', 'ign'].include?(cgi.params[e][0])
69 filters[e] = cgi.params[e][0]
70 else
71 filters[e] = (e == 'merged' ? 'ign' : '')
72 end
73 end
74 # filter: newer than X days
75 if ['', 'only', 'ign'].include?(cgi.params['fnewer'][0])
76 fnewer = cgi.params['fnewer'][0]
77 else
78 fnewer = ''
79 end
80 if cgi.params['fnewerval'][0] =~ /^[0-9]+$/
81 fnewerval = cgi.params['fnewerval'][0].to_i
82 else
83 fnewerval = 7
84 end
85 # types
86 types = {}
87 TYPES.each do |t|
88 if cgi.params == {}
89 types[t[0]] = t[3]
90 else
91 if cgi.params[t[0]][0] == '1'
92 types[t[0]] = true
93 else
94 types[t[0]] = false
95 end
96 end
97 end
98
99 puts <<-EOF
100 <html>
101 <head>
102 <style type="text/css">
103
104 body {
105 font-family : "DejaVu Sans", "Bitstream Vera Sans", sans-serif;"
106 }
107
108 table.buglist td, table.buglist th {
109 border: 1px solid gray;
110 padding-left: 3px;
111 padding-right: 3px;
112 }
113 table.buglist tr:hover {
114 background-color: #ccc;
115 }
116 table {
117 border-collapse: collapse;
118 }
119
120 div#body {
121 border-top: 2px solid #d70751;
122 }
123
124 div.footer {
125 padding: 0.3em 0;
126 background-color: #fff;
127 text-align: center;
128 border-top: 2px solid #d70751;
129 margin: 0 0 0 0;
130 border-bottom: 0;
131 font-size: 85%;
132 }
133 </style>
134 <title>Debian Bugs Search @ UDD</title>
135 </head>
136 <body>
137 <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>
138 <div id="body">
139
140 <form action="bugs.cgi" method="get">
141 <p><b>Bugs affecting:</b>
142 EOF
143
144 RELEASE_RESTRICT.each do |r|
145 checked = (release == r[0] ? 'CHECKED=\'1\'':'')
146 puts "<input type='radio' name='release' value='#{r[0]}' #{checked}/>#{r[1]}&nbsp;&nbsp;"
147 end
148 puts <<-EOF
149 <br/>(also uses release tags and xxx-ignore information)</p>
150 <table class="invisible"><tr><td>
151 <table class="buglist">
152 <tr><th colspan='4'>FILTERS</th></tr>
153 <tr><th>not considered</th><th>only</th><th>ignore</th><th>type</th></tr>
154 EOF
155 FILTERS.each do |r|
156 puts <<-EOF
157 <tr>
158 <td style='text-align: center;'><input type='radio' name='#{r[0]}' value='' #{filters[r[0]]==''?'CHECKED=\'1\'':''}/></td>
159 <td style='text-align: center;'><input type='radio' name='#{r[0]}' value='only' #{filters[r[0]]=='only'?'CHECKED=\'1\'':''}/></td>
160 <td style='text-align: center;'><input type='radio' name='#{r[0]}' value='ign' #{filters[r[0]]=='ign'?'CHECKED=\'1\'':''}'/></td>
161 <td>#{r[1]}</td>
162 </tr>
163 EOF
164 end
165 # newer than
166 puts <<-EOF
167 <tr>
168 <td style='text-align: center;'><input type='radio' name='fnewer' value='' #{fnewer==''?'CHECKED=\'1\'':''}/></td>
169 <td style='text-align: center;'><input type='radio' name='fnewer' value='only' #{fnewer=='only'?'CHECKED=\'1\'':''}/></td>
170 <td style='text-align: center;'><input type='radio' name='fnewer' value='ign' #{fnewer=='ign'?'CHECKED=\'1\'':''}'/></td>
171 <td>newer than <input type='text' size='3' name='fnewerval' value='#{fnewerval}'/> days</td>
172 </tr>
173 EOF
174 puts "</table></td><td style='padding-left: 20px'><table class='buglist'>"
175 puts "<tr><th colspan='2'>Bug types</th></tr>"
176 TYPES.each do |t|
177 checked = types[t[0]]?" checked='1'":""
178 puts "<tr><td><input type='checkbox' name='#{t[0]}' value='1'#{checked}/></td><td>#{t[1]}</td></tr>"
179 end
180 puts "</table></td></tr></table>"
181 puts "<p><b>Sort by:</b> "
182 SORTS.each do |r|
183 checked = (sortby == r[0] ? 'CHECKED=\'1\'':'')
184 puts "<input type='radio' name='sortby' value='#{r[0]}' #{checked}/>#{r[1]}&nbsp;&nbsp;"
185 end
186 puts "<b> -- </b>"
187 [['asc', 'increasing'],[ 'desc', 'decreasing']].each do |r|
188 checked = (sorto == r[0] ? 'CHECKED=\'1\'':'')
189 puts "<input type='radio' name='sorto' value='#{r[0]}' #{checked}/>#{r[1]}&nbsp;&nbsp;"
190 end
191 puts <<-EOF
192 </p><input type='submit' value='Search'/>
193 </form>
194 EOF
195 if cgi.params != {}
196
197 # Generate and execute query
198 tstart = Time::now
199 dbh = DBI::connect('DBI:Pg:dbname=udd;port=5441;host=localhost', 'guest')
200 if sortby != 'popcon'
201 q = "select id, bugs.package, bugs.source, title, last_modified from bugs \n"
202 else
203 q = "select id, bugs.package, bugs.source, title, last_modified, coalesce(popcon_src.insts, 0) as popcon\nfrom bugs left join popcon_src on (bugs.source = popcon_src.source) \n"
204 end
205 q += "where #{RELEASE_RESTRICT.select { |r| r[0] == release }[0][2]} \n"
206 FILTERS.each do |f|
207 if filters[f[0]] == 'only'
208 q += "and #{f[2]} \n"
209 elsif filters[f[0]] == 'ign'
210 q += "and not (#{f[2]}) \n"
211 end
212 end
213 if fnewer == 'only'
214 q += "and (current_timestamp - interval '#{fnewerval} days' <= arrival) \n"
215 elsif fnewer == 'ign'
216 q += "and (current_timestamp - interval '#{fnewerval} days' > arrival) \n"
217 end
218 q2 = TYPES.select { |t| types[t[0]] }.map { |t| t[2] }.join("\n OR ")
219 if q2 != ""
220 q += "AND (#{q2})\n"
221 else
222 puts "<p><b>Must select at least one bug type!</b></p>"
223 q += "AND FALSE\n"
224 end
225 q += "order by #{sortby} #{sorto}"
226 sth = dbh.prepare(q)
227 sth.execute
228 rows = sth.fetch_all
229
230 puts "<p><b>#{rows.length} bugs found.</b></p>"
231 puts '<table class="buglist">'
232 if sortby != 'popcon'
233 puts '<tr><th>bug#</th><th>package</th><th>title</th><th>last&nbsp;modified</th></tr>'
234 else
235 puts '<tr><th>bug#</th><th>package</th><th>title</th><th>popcon</th><th>last&nbsp;modified</th></tr>'
236 end
237
238 rows.each do |r|
239 puts "<tr><td style='text-align: center;'><a href=\"http://bugs.debian.org/#{r['id']}\">##{r['id']}</a></td>"
240 puts "<td style='text-align: center;'>"
241 srcs = r['source'].split(/,\s*/)
242 bins = r['package'].split(/,\s*/)
243 puts (0...bins.length).map { |i| "<a href=\"http://packages.qa.debian.org/#{srcs[i]}\">#{bins[i]}</a>" }.join(', ')
244 puts "</td>"
245 puts "<td>#{CGI::escapeHTML(r['title'])}</td>"
246 if sortby == 'popcon'
247 puts "<td>#{r['popcon']}</td>"
248 end
249 puts "<td style='text-align: center;'>#{r['last_modified'].to_date}</td></tr>"
250 end
251 =begin
252 release goals:
253 all
254 include / only
255
256 columns:
257 id
258 source
259 package
260 title
261
262 time
263 data last refreshed
264 EOF
265 =end
266
267 =begin
268 sth = dbh.prepare("select id, bugs.package, bugs.source, insts, title from bugs, popcon_src where bugs.source = popcon_src.source and id in (select id from bugs_rt_affects_testing_and_unstable) and id in (select id from bugs_tags where tag='patch') and id not in (select id from bugs_tags where tag='pending') and severity >= 'serious' order by id")
269 sth.execute ; rows = sth.fetch_all
270
271 puts "<h2>RC bugs tagged patch (and not pending)</h2>"
272 puts "<table>"
273 puts "<tr><th>bug</th><th>package</th><th>source</th><th>popcon</th><th>title</th></tr>"
274 rows.each do |r|
275 puts "<tr><td><a href=\"http://bugs.debian.org/#{r['id']}\">#{r['id']}</a></td>"
276 puts "<td>#{r['package']}</td>"
277 puts "<td><a href=\"http://packages.qa.debian.org/#{r['source']}\">#{r['source']}</a></td>"
278 puts "<td>#{r['insts']}</td>"
279 puts "<td>#{r['title']}</td>"
280 end
281 puts "</table>"
282 sth.finish
283
284 puts "<h2>RC bugs on packages with a newer version in Ubuntu (possible patches), not tagged patch nor pending</h2>"
285 puts "<table>"
286 puts "<tr><th>bug</th><th>package</th><th>source</th><th>versions (D/U)</th><th>popcon</th><th>title</th></tr>"
287
288 sth = dbh.prepare("WITH ubudeb AS (select distinct on (d.source, u.source) d.source as dsource, u.source as usource, d.version as dversion, u.version as uversion from sources_uniq d, ubuntu_sources u where d.release = 'sid' and d.distribution = 'debian' and u.release = '#{URELEASE}' and u.distribution = 'ubuntu' and u.source = d.source and u.version > d.version order by d.source asc, u.source asc, d.version desc)
289 select id, bugs.package, bugs.source, title, dversion, uversion, insts from bugs, ubudeb, popcon_src where popcon_src.source = bugs.source and id in (select id from bugs_rt_affects_testing_and_unstable) and id not in (select id from bugs_tags where tag='patch') and id not in (select id from bugs_tags where tag='pending') and severity >= 'serious' and ubudeb.dsource = bugs.source order by id")
290 sth.execute ; rows = sth.fetch_all
291 rows.each do |r|
292 puts "<tr><td><a href=\"http://bugs.debian.org/#{r['id']}\">#{r['id']}</a></td>"
293 puts "<td>#{r['package']}</td>"
294 puts "<td><a href=\"http://packages.qa.debian.org/#{r['source']}\">#{r['source']}</a> <a href=\"https://launchpad.net/ubuntu/#{URELEASE}/+source/#{r['source']}/+changelog\">UbCh</a></td>"
295 puts "<td>#{r['dversion']} / #{r['uversion']}</td>"
296 puts "<td>#{r['insts']}</td>"
297 puts "<td>#{r['title']}</td>"
298 end
299 puts "</table>"
300 sth.finish
301
302 sth = dbh.prepare("select id, bugs.package, bugs.source, insts, title from bugs, popcon_src where bugs.source = popcon_src.source and id in (select id from bugs_rt_affects_testing) and id not in (select id from bugs_rt_affects_unstable) and severity >= 'serious' order by package")
303 sth.execute ; rows = sth.fetch_all
304
305 puts "<h2>RC bugs affecting only testing (not unstable, and not pending)</h2>"
306 puts "<table>"
307 puts "<tr><th>bug</th><th>package</th><th>source</th><th>popcon</th><th>title</th></tr>"
308 rows.each do |r|
309 puts "<tr><td><a href=\"http://bugs.debian.org/#{r['id']}\">#{r['id']}</a></td>"
310 puts "<td>#{r['package']}</td>"
311 puts "<td><a href=\"http://packages.qa.debian.org/#{r['source']}\">#{r['source']}</a></td>"
312 puts "<td>#{r['insts']}</td>"
313 puts "<td>#{r['title']}</td>"
314 end
315 puts "</table>"
316 sth.finish
317
318 =end
319 puts "</table>"
320 sth2 = dbh.prepare("select max(start_time) from timestamps where source = 'bugs' and command = 'run'")
321 sth2.execute ; r2 = sth2.fetch_all
322 puts "<p><b>Generated in #{Time::now - tstart} seconds. Last data update: #{r2[0][0]}"
323 puts " (%.1f hours ago)</b></p>" % ((Time::now - r2[0][0].to_time) / 3600)
324 puts "<pre>#{q}</pre>"
325 end # if cgi.params != {}
326 puts <<-EOF
327 </div>
328 <div class="footer">
329 <small>Suggestions / comments / patches to lucas@debian.org. <a href="http://svn.debian.org/wsvn/collab-qa/udd/web/cgi-bin/bugs.cgi">source code</a>.</small>
330 </div>
331 </body>
332 </html>
333 EOF

Properties

Name Value
svn:executable *
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.5