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

Contents of /udd/web/bugs.cgi

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.5