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

Contents of /udd/web/bugs.cgi

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.5