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

Diff of /udd/web/bugs.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

udd/web/cgi-bin/bugs.cgi revision 1787 by lucas, Mon Sep 13 13:32:51 2010 UTC udd/web/bugs.cgi revision 1799 by lucas, Sat Sep 18 11:05:59 2010 UTC
# Line 9  puts "Content-type: text/html\n\n" Line 9  puts "Content-type: text/html\n\n"
9  RELEASE_RESTRICT = [  RELEASE_RESTRICT = [
10    ['squeeze', 'squeeze', 'id in (select id from bugs_rt_affects_testing)'],    ['squeeze', 'squeeze', 'id in (select id from bugs_rt_affects_testing)'],
11    ['sid', 'sid', 'id in (select id from bugs_rt_affects_unstable)'],    ['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_unstable)'],    ['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)'],    ['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)'],    ['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)']    ['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 = [  FILTERS = [
# Line 23  FILTERS = [ Line 24  FILTERS = [
24   ['notsqueeze', 'packages not in squeeze', 'id not in (select id from bugs_packages, sources where bugs_packages.source = sources.source and release=\'squeeze\')'],   ['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)'],   ['merged', 'merged bugs', 'id in (select id from bugs_merged_with where id > merged_with)'],
26   ['done', 'marked as done', 'status = \'done\''],   ['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     ['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  ]  ]
32    
33  TYPES = [  TYPES = [
# Line 37  SORTS = [ Line 42  SORTS = [
42    ['id', 'bug#'],    ['id', 'bug#'],
43    ['source', 'source package'],    ['source', 'source package'],
44    ['package', 'binary package'],    ['package', 'binary package'],
45    ['last_modified', 'last modified']    ['last_modified', 'last modified'],
46      ['popcon', 'popularity contest'],
47  ]  ]
48    
49  cgi = CGI::new  cgi = CGI::new
# Line 61  end Line 67  end
67  # filters  # filters
68  filters = {}  filters = {}
69  FILTERS.map { |r| r[0] }.each do |e|  FILTERS.map { |r| r[0] }.each do |e|
70    if ['notconsidered', 'only', 'ign'].include?(cgi.params[e][0])    if ['', 'only', 'ign'].include?(cgi.params[e][0])
71      filters[e] = cgi.params[e][0]      filters[e] = cgi.params[e][0]
72    else    else
73      filters[e] = (e == 'merged' ? 'ign' : 'notconsidered')      filters[e] = (e == 'merged' ? 'ign' : '')
74    end    end
75  end  end
76  # filter: newer than X days  # filter: newer than X days
77  if ['notconsidered', 'only', 'ign'].include?(cgi.params['fnewer'][0])  if ['', 'only', 'ign'].include?(cgi.params['fnewer'][0])
78    fnewer = cgi.params['fnewer'][0]    fnewer = cgi.params['fnewer'][0]
79  else  else
80    fnewer = 'notconsidered'    fnewer = ''
81  end  end
82  if cgi.params['fnewerval'][0] =~ /^[0-9]+$/  if cgi.params['fnewerval'][0] =~ /^[0-9]+$/
83    fnewerval = cgi.params['fnewerval'][0].to_i    fnewerval = cgi.params['fnewerval'][0].to_i
# Line 96  puts <<-EOF Line 102  puts <<-EOF
102  <html>  <html>
103  <head>  <head>
104  <style type="text/css">  <style type="text/css">
105    
106      body {
107        font-family : "DejaVu Sans", "Bitstream Vera Sans", sans-serif;"
108      }
109    
110    table.buglist td, table.buglist th {    table.buglist td, table.buglist th {
111      border: 1px solid gray;      border: 1px solid gray;
112      padding-left: 3px;      padding-left: 3px;
# Line 108  puts <<-EOF Line 119  puts <<-EOF
119      border-collapse: collapse;      border-collapse: collapse;
120    }    }
121    
122    div#body {
123      border-top: 2px solid #d70751;
124    }
125    
126    div.footer {
127        padding: 0.3em 0;
128        background-color: #fff;
129        text-align: center;
130        border-top: 2px solid #d70751;
131        margin: 0 0 0 0;
132        border-bottom: 0;
133        font-size: 85%;
134    }
135  </style>  </style>
136  <title>RC Bugs List @ UDD</title>  <title>Debian Bugs Search @ UDD</title>
137  </head>  </head>
138  <body>  <body>
139  <h1>Release Critical Bugs List</h1>  <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>
140    <div id="body">
141    
142  <form action="bugs.cgi" method="get">  <form action="bugs.cgi" method="get">
143  <p><b>Bugs affecting:</b>  <p><b>Bugs affecting:</b>
# Line 123  RELEASE_RESTRICT.each do |r| Line 148  RELEASE_RESTRICT.each do |r|
148    puts "<input type='radio' name='release' value='#{r[0]}' #{checked}/>#{r[1]}&nbsp;&nbsp;"    puts "<input type='radio' name='release' value='#{r[0]}' #{checked}/>#{r[1]}&nbsp;&nbsp;"
149  end  end
150  puts <<-EOF  puts <<-EOF
151  </p>  <br/>(also uses release tags and xxx-ignore information)</p>
152  <table class="invisible"><tr><td>  <table class="invisible"><tr><td>
153  <table class="buglist">  <table class="buglist">
154  <tr><th colspan='4'>FILTERS</th></tr>  <tr><th colspan='4'>FILTERS</th></tr>
# Line 132  EOF Line 157  EOF
157  FILTERS.each do |r|  FILTERS.each do |r|
158    puts <<-EOF    puts <<-EOF
159    <tr>    <tr>
160    <td style='text-align: center;'><input type='radio' name='#{r[0]}' value='' #{filters[r[0]]=='notconsidered'?'CHECKED=\'1\'':''}/></td>    <td style='text-align: center;'><input type='radio' name='#{r[0]}' value='' #{filters[r[0]]==''?'CHECKED=\'1\'':''}/></td>
161    <td style='text-align: center;'><input type='radio' name='#{r[0]}' value='only' #{filters[r[0]]=='only'?'CHECKED=\'1\'':''}/></td>    <td style='text-align: center;'><input type='radio' name='#{r[0]}' value='only' #{filters[r[0]]=='only'?'CHECKED=\'1\'':''}/></td>
162    <td style='text-align: center;'><input type='radio' name='#{r[0]}' value='ign' #{filters[r[0]]=='ign'?'CHECKED=\'1\'':''}'/></td>    <td style='text-align: center;'><input type='radio' name='#{r[0]}' value='ign' #{filters[r[0]]=='ign'?'CHECKED=\'1\'':''}'/></td>
163    <td>#{r[1]}</td>    <td>#{r[1]}</td>
# Line 142  end Line 167  end
167  # newer than  # newer than
168  puts <<-EOF  puts <<-EOF
169    <tr>    <tr>
170    <td style='text-align: center;'><input type='radio' name='fnewer' value='' #{fnewer=='notconsidered'?'CHECKED=\'1\'':''}/></td>    <td style='text-align: center;'><input type='radio' name='fnewer' value='' #{fnewer==''?'CHECKED=\'1\'':''}/></td>
171    <td style='text-align: center;'><input type='radio' name='fnewer' value='only' #{fnewer=='only'?'CHECKED=\'1\'':''}/></td>    <td style='text-align: center;'><input type='radio' name='fnewer' value='only' #{fnewer=='only'?'CHECKED=\'1\'':''}/></td>
172    <td style='text-align: center;'><input type='radio' name='fnewer' value='ign' #{fnewer=='ign'?'CHECKED=\'1\'':''}'/></td>    <td style='text-align: center;'><input type='radio' name='fnewer' value='ign' #{fnewer=='ign'?'CHECKED=\'1\'':''}'/></td>
173    <td>newer than <input type='text' size='3' name='fnewerval' value='#{fnewerval}'/> days</td>    <td>newer than <input type='text' size='3' name='fnewerval' value='#{fnewerval}'/> days</td>
# Line 166  puts "<b> -- </b>" Line 191  puts "<b> -- </b>"
191    puts "<input type='radio' name='sorto' value='#{r[0]}' #{checked}/>#{r[1]}&nbsp;&nbsp;"    puts "<input type='radio' name='sorto' value='#{r[0]}' #{checked}/>#{r[1]}&nbsp;&nbsp;"
192  end  end
193  puts <<-EOF  puts <<-EOF
194  </p><input type='submit' value='Update'/>  </p><input type='submit' value='Search'/>
195  </form>  </form>
196  EOF  EOF
197  if cgi.params != {}  if cgi.params != {}
# Line 174  if cgi.params != {} Line 199  if cgi.params != {}
199  # Generate and execute query  # Generate and execute query
200  tstart = Time::now  tstart = Time::now
201  dbh = DBI::connect('DBI:Pg:dbname=udd;port=5441;host=localhost', 'guest')  dbh = DBI::connect('DBI:Pg:dbname=udd;port=5441;host=localhost', 'guest')
202  q = "select id, bugs.package, bugs.source, title, last_modified from bugs \n"  if sortby != 'popcon'
203      q = "select id, bugs.package, bugs.source, title, last_modified from bugs \n"
204    else
205      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"
206    end
207  q += "where #{RELEASE_RESTRICT.select { |r| r[0] == release }[0][2]} \n"  q += "where #{RELEASE_RESTRICT.select { |r| r[0] == release }[0][2]} \n"
208  FILTERS.each do |f|  FILTERS.each do |f|
209    if filters[f[0]] == 'only'    if filters[f[0]] == 'only'
# Line 188  if fnewer == 'only' Line 217  if fnewer == 'only'
217  elsif fnewer == 'ign'  elsif fnewer == 'ign'
218    q += "and (current_timestamp - interval '#{fnewerval} days' > arrival) \n"    q += "and (current_timestamp - interval '#{fnewerval} days' > arrival) \n"
219  end  end
220  q += "AND ("  q2 = TYPES.select { |t| types[t[0]] }.map { |t| t[2] }.join("\n OR ")
221  q += TYPES.select { |t| types[t[0]] }.map { |t| t[2] }.join("\n OR ")  if q2 != ""
222  q += ")\n "    q += "AND (#{q2})\n"
223    else
224      puts "<p><b>Must select at least one bug type!</b></p>"
225      q += "AND FALSE\n"
226    end
227  q += "order by #{sortby} #{sorto}"  q += "order by #{sortby} #{sorto}"
228  sth = dbh.prepare(q)  sth = dbh.prepare(q)
229  sth.execute  sth.execute
230  rows = sth.fetch_all  rows = sth.fetch_all
231    
232  puts "<p><b>#{rows.length} bugs found.</b></p>"  puts "<p><b>#{rows.length} bugs found.</b></p>"
233  puts <<-EOF  puts '<table class="buglist">'
234  <table class="buglist">  if sortby != 'popcon'
235  <tr><th>bug#</th><th>source pkg</th><th>binary pkg</th><th>title</th><th>last&nbsp;modified</th></tr>    puts '<tr><th>bug#</th><th>package</th><th>title</th><th>last&nbsp;modified</th></tr>'
236  EOF  else
237      puts '<tr><th>bug#</th><th>package</th><th>title</th><th>popcon</th><th>last&nbsp;modified</th></tr>'
238    end
239    
240  rows.each do |r|  rows.each do |r|
241    puts "<tr><td style='text-align: center;'><a href=\"http://bugs.debian.org/#{r['id']}\">##{r['id']}</a></td>"    puts "<tr><td style='text-align: center;'><a href=\"http://bugs.debian.org/#{r['id']}\">##{r['id']}</a></td>"
242    puts "<td style='text-align: center;'>"    puts "<td style='text-align: center;'>"
243    puts r['source'].split(/,\s*/).map { |pkg| "<a href=\"http://packages.qa.debian.org/#{pkg}\">#{pkg}</a>" }.join(', ')    srcs = r['source'].split(/,\s*/)
244      bins = r['package'].split(/,\s*/)
245      puts (0...bins.length).map { |i| "<a href=\"http://packages.qa.debian.org/#{srcs[i]}\">#{bins[i]}</a>" }.join(', ')
246    puts "</td>"    puts "</td>"
247    puts <<-EOF    puts "<td>#{CGI::escapeHTML(r['title'])}</td>"
248    <td style='text-align: center;'>#{r['package']}</td>    if sortby == 'popcon'
249    <td>#{r['title']}</td>      puts "<td>#{r['popcon']}</td>"
250    <td style='text-align: center;'>#{r['last_modified'].to_date}</td>    end
251    </tr>    puts "<td style='text-align: center;'>#{r['last_modified'].to_date}</td></tr>"
   EOF  
252  end  end
253  =begin  =begin
254  release goals:  release goals:
# Line 284  sth.finish Line 321  sth.finish
321  puts "</table>"  puts "</table>"
322  sth2 = dbh.prepare("select max(start_time) from timestamps where source = 'bugs' and command = 'run'")  sth2 = dbh.prepare("select max(start_time) from timestamps where source = 'bugs' and command = 'run'")
323  sth2.execute ; r2 = sth2.fetch_all  sth2.execute ; r2 = sth2.fetch_all
324  puts "<p><b>Generated in #{Time::now - tstart} seconds. Last data update: #{r2[0][0]}</b></p>"  puts "<p><b>Generated in #{Time::now - tstart} seconds. Last data update: #{r2[0][0]}"
325    puts " (%.1f hours ago)</b></p>" % ((Time::now - r2[0][0].to_time) / 3600)
326  puts "<pre>#{q}</pre>"  puts "<pre>#{q}</pre>"
327  end # if cgi.params != {}  end # if cgi.params != {}
328  puts <<-EOF  puts <<-EOF
329  <hr/>  </div>
330  <small>Suggestions / comments / patches to lucas at debian dot org. <a href="http://svn.debian.org/wsvn/collab-qa/udd/web/cgi-bin/bugs.cgi">source code</a>.</small>  <div class="footer">
331    <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>
332    </div>
333  </body>  </body>
334  </html>  </html>
335  EOF  EOF

Legend:
Removed from v.1787  
changed lines
  Added in v.1799

  ViewVC Help
Powered by ViewVC 1.1.5