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

Contents of /udd/web/bugs.cgi

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.5