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

Diff of /udd/web/bapase.cgi

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

udd/web/cgi-bin/bapase.cgi revision 1575 by lucas, Sat Sep 5 12:56:33 2009 UTC udd/web/bapase.cgi revision 1905 by lucas, Mon Feb 7 07:50:34 2011 UTC
# Line 1  Line 1 
1  #!/usr/bin/ruby -w  #!/usr/bin/ruby -w
2  require 'dbi'  require 'dbi'
3  require 'cgi'  require 'cgi'
4  require 'actions'  
5    tstart = Time::now
6    
7    class Actions
8      attr_reader :actions, :act_todo, :act_status, :act_comment
9      def initialize
10        @actions = []
11        @act_status = ""
12        @act_todo = false
13        @act_comment = ""
14      end
15    
16      def add(desc)
17        desc.chomp!
18        date, who, act, comment = desc.split(' ', 4)
19        date = Date::parse(date)
20        if act =~ /^(.+)\((.+)\)$/
21          act_name, act_arg = $1, $2
22          if [ 'PROP_RM', 'PROP_RM_O', 'PROP_O', 'O', 'REQ_RM', 'RM', 'SEC_RM', 'O_PROP_RM' ].include?(act_name)
23            # FIXME check bug
24          elsif act_name == 'WAIT'
25            act_arg = act_arg.to_i
26          else
27            puts "Unknown action: #{act} (#{desc})"
28          end
29          @actions << [date, who, [act_name, act_arg], comment]
30        elsif act == 'OK'
31          act_name = 'OK'
32          act_arg = nil
33          @actions << [date, who, [act_name, act_arg], comment]
34        else
35          puts "Unparseable action: #{act} (#{desc})"
36          exit(1)
37        end
38      end
39    
40      def analyze_actions
41        @actions.sort! { |a,b| b[0] <=> a[0] }
42        idx = 0
43        rm_o = false
44        while idx < @actions.length
45          if @actions[idx][2][0] == 'OK'
46            @act_status = ""
47            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
48            break
49          elsif @actions[idx][2][0] == 'WAIT'
50            if @actions[idx][0] + @actions[idx][2][1] <= CURDATE
51              idx += 1
52              next # OK not valid anymore, consider next action
53            else
54              # nothing to do except waiting
55              @act_status = "Waiting until #{@actions[idx][0] + @actions[idx][2][1]}"
56              @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
57              break
58            end
59          elsif @actions[idx][2][0] == 'REQ_RM' or @actions[idx][2][0] == 'RM'
60            @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Removal was requested</a>"
61            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
62            break
63          elsif @actions[idx][2][0] == 'O'
64            @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Was orphaned</a>"
65            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
66            break
67          elsif @actions[idx][2][0] == 'PROP_RM_O'
68            @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Was orphaned, will need removal</a>"
69            rm_o = true
70            idx += 1
71            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
72            next
73          elsif @actions[idx][2][0] == 'PROP_RM'
74            ok = false
75            if @actions[idx][0] + WAIT_RM_O <= CURDATE and !rm_o
76              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Should be orphaned before removal (since #{@actions[idx][0] + 50})</a>"
77              @act_todo = true
78              ok = true
79            end
80            if @actions[idx][0] + WAIT_RM_RM <= CURDATE
81              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Should be removed (since #{@actions[idx][0] + 100})</a>"
82              @act_todo = true
83              ok = true
84            end
85            if !ok
86              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Removal suggested (since #{@actions[idx][0]})</a>"
87            end
88            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
89            break
90          elsif @actions[idx][2][0] == 'PROP_O'
91            if @actions[idx][0] + WAIT_O_O <= CURDATE
92              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Should be orphaned (since #{@actions[idx][0] + 50})</a>"
93              @act_todo = true
94            else
95              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Orphaning suggested (since #{@actions[idx][0]})</a>"
96            end
97            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
98            break
99          elsif @actions[idx][2][0] == 'O_PROP_RM'
100            if @actions[idx][0] + WAIT_ORM_RM <= CURDATE
101              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Should be removed (O pkg) (since #{@actions[idx][0] + 50})</a>"
102              @act_todo = true
103            else
104              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Removal suggested (O pkg) (since #{@actions[idx][0]})</a>"
105            end
106            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
107            break
108          else
109            puts "Unknown act: #{@actions[idx][2][0]}"
110          end
111        end
112      end
113    
114      def Actions::fetch
115        d = IO::popen("svn cat svn://svn.debian.org/collab-qa/bapase/package-actions.txt")
116        f = d.read
117        d.close
118        return Actions::read(f)
119      end
120    
121      def Actions::read(data)
122        pkgs = {}
123        data.each_line do |l|
124          next if l =~/^\s*#/ or l =~/^\s*$/
125          pkg, rest = l.split(' ',2)
126          if pkgs[pkg].nil?
127            pkgs[pkg] = Actions::new
128          end
129          pkgs[pkg].add(rest)
130        end
131        pkgs.each_pair { |k, v| v.analyze_actions }
132      end
133    end
134    
135  puts "Content-type: text/html\n\n"  puts "Content-type: text/html\n\n"
136    
# Line 23  end Line 152  end
152    
153  if type == 'o'  if type == 'o'
154    orphaned = true    orphaned = true
155    query = "select * from bapase where type is not null order by orphaned_age desc"    query = "select * from bapase where type is not null and type in ('O', 'ITA') order by orphaned_age desc"
156    elsif type == 'rfa'
157      orphaned = true
158      query = "select * from bapase where type is not null and type in ('RFA') order by orphaned_age desc"
159  elsif type == 'nmu'  elsif type == 'nmu'
160    orphaned = true    orphaned = true
161    query = "select * from bapase where nmu and nmus > 1 order by nmus desc"    query = "select * from bapase where nmu and nmus > 1 order by nmus desc"
162  elsif type == 'testing'  elsif type == 'testing'
163    orphaned = true    orphaned = true
164    query = "select * from bapase where source not in (select source from sources where distribution='debian' and release='squeeze') order by testing_age desc, first_seen asc"    query = "select * from bapase where source not in (select source from sources where distribution='debian' and release='wheezy') order by testing_age desc, first_seen asc"
165  elsif type == 'nodd'  elsif type == 'nodd'
166    orphaned = true    orphaned = true
167    query = <<EOF    query = <<EOF
168    WITH active_emails AS (SELECT email FROM carnivore_emails, active_dds WHERE active_dds.id = carnivore_emails.id)
169  select * from bapase where source in (  select * from bapase where source in (
170  SELECT source  SELECT source
171  FROM sources  FROM sources
# Line 42  SELECT sources.source Line 175  SELECT sources.source
175  FROM sources  FROM sources
176  LEFT OUTER JOIN uploaders ON (sources.source = uploaders.source AND sources.version = uploaders.version AND sources.distribution = uploaders.distribution AND sources.release = uploaders.release AND sources.component = uploaders.component)  LEFT OUTER JOIN uploaders ON (sources.source = uploaders.source AND sources.version = uploaders.version AND sources.distribution = uploaders.distribution AND sources.release = uploaders.release AND sources.component = uploaders.component)
177  WHERE sources.distribution = 'debian' AND sources.release = 'sid'  WHERE sources.distribution = 'debian' AND sources.release = 'sid'
178  AND (maintainer_email in (SELECT email FROM carnivore_emails, active_dds WHERE active_dds.id = carnivore_emails.id)  AND (maintainer_email in (select email from active_emails)
179  OR email in (SELECT email FROM carnivore_emails, active_dds WHERE active_dds.id = carnivore_emails.id)  OR email in (SELECT email FROM active_emails)
180  OR maintainer_email ~ '.*@lists.(alioth.)?debian.org'  OR maintainer_email ~ '.*@lists.(alioth.)?debian.org'
181  OR email ~ '.*@lists.(alioth.)?debian.org'))  OR email ~ '.*@lists.(alioth.)?debian.org'))
182  ) order by upload_age desc  ) order by upload_age desc
# Line 52  elsif type == 'maintnmu' Line 185  elsif type == 'maintnmu'
185    orphaned = true    orphaned = true
186    query = <<EOF    query = <<EOF
187  select * from bapase where source in (  select * from bapase where source in (
188    select source from sources where distribution='debian' and release='squeeze' and maintainer_email in (    select source from sources where distribution='debian' and release='wheezy' and maintainer_email in (
189  select nmus.email from  select nmus.email from
190  (select email, count(*) as tot from  (select email, count(*) as tot from
191  (select maintainer_email as email, source from sources  (select maintainer_email as email, source from sources_uniq
192  where release = 'sid'  where release = 'sid'
193  and distribution = 'debian'  and distribution = 'debian'
194  and component = 'main'  and component = 'main'
# Line 66  and distribution = 'debian' Line 199  and distribution = 'debian'
199  and component = 'main') as foo  and component = 'main') as foo
200  group by email) as tot,  group by email) as tot,
201  (select email, count(*) as nmus from  (select email, count(*) as nmus from
202  (select sources.maintainer_email as email, sources.source from sources, upload_history uh  (select sources.maintainer_email as email, sources.source from sources_uniq sources, upload_history uh
203  where release = 'sid'  where release = 'sid'
204  and distribution = 'debian'  and distribution = 'debian'
205  and component = 'main'  and component = 'main'
# Line 83  and uh.nmu Line 216  and uh.nmu
216  group by email) as nmus  group by email) as nmus
217  where nmus * 100 / tot >= 100  where nmus * 100 / tot >= 100
218  and nmus.email = tot.email)  and nmus.email = tot.email)
219  union (select source from uploaders where distribution='debian' and release='squeeze' and email in (  union (select source from uploaders where distribution='debian' and release='wheezy' and email in (
220  select nmus.email from  select nmus.email from
221  (select email, count(*) as tot from  (select email, count(*) as tot from
222  (select maintainer_email as email, source from sources  (select maintainer_email as email, source from sources_uniq sources
223  where release = 'sid'  where release = 'sid'
224  and distribution = 'debian'  and distribution = 'debian'
225  and component = 'main'  and component = 'main'
# Line 97  and distribution = 'debian' Line 230  and distribution = 'debian'
230  and component = 'main') as foo  and component = 'main') as foo
231  group by email) as tot,  group by email) as tot,
232  (select email, count(*) as nmus from  (select email, count(*) as nmus from
233  (select sources.maintainer_email as email, sources.source from sources, upload_history uh  (select sources.maintainer_email as email, sources.source from sources_uniq sources, upload_history uh
234  where release = 'sid'  where release = 'sid'
235  and distribution = 'debian'  and distribution = 'debian'
236  and component = 'main'  and component = 'main'
# Line 118  and nmus.email = tot.email Line 251  and nmus.email = tot.email
251  EOF  EOF
252  else  else
253    puts <<-EOF    puts <<-EOF
254    <a href="bapase.cgi?t=o">Orphaned packages</a><br/>    <h1>Bapase</h1>
255    <a href="bapase.cgi?t=nmu">Packages maintained with NMUs</a><br/>    <ul>
256    <a href="bapase.cgi?t=testing">Packages not in testing</a><br/>    <li><a href="bapase.cgi?t=o">Orphaned packages</a></li>
257    <a href="bapase.cgi?t=nodd">Packages not maintained by DDs</a><br/>    <li><a href="bapase.cgi?t=rfa">RFAed packages</a></li>
258    <a href="bapase.cgi?t=maintnmu">Packages maintained or co-maintained by people with lots of NMUs</a><br/>    <li><a href="bapase.cgi?t=nmu">Packages maintained with NMUs</a></li>
259      <li><a href="bapase.cgi?t=testing">Packages not in testing</a></li>
260      <li><a href="bapase.cgi?t=nodd">Packages not maintained by DDs</a></li>
261      <li><a href="bapase.cgi?t=maintnmu">Packages maintained or co-maintained by people with lots of NMUs</a></li>
262      </ul>
263    </body></html>    </body></html>
264    EOF    EOF
265    exit(0)    exit(0)
# Line 166  puts <<-EOF Line 303  puts <<-EOF
303  <th>Comments</th>  <th>Comments</th>
304  </tr>  </tr>
305  EOF  EOF
306    tqs = Time::now
307  sth = dbh.prepare(query)  sth = dbh.prepare(query)
308  sth.execute  sth.execute
309    tqe = Time::now
310  res = sth.fetch_all  res = sth.fetch_all
311  n = 0  n = 0
312  res.each do |r|  res.each do |r|
# Line 206  res.each do |r| Line 345  res.each do |r|
345    puts "<td><a href=\"http://bugs.debian.org/src:#{pkg}\">#{r['rc_bugs']}&nbsp;/&nbsp;#{r['all_bugs']}</a></td>"    puts "<td><a href=\"http://bugs.debian.org/src:#{pkg}\">#{r['rc_bugs']}&nbsp;/&nbsp;#{r['all_bugs']}</a></td>"
346    puts "<td>#{r['upload_age']}</td>"    puts "<td>#{r['upload_age']}</td>"
347    puts "<td>#{r['nmus']}</td>"    puts "<td>#{r['nmus']}</td>"
   puts "<td></td>"  
348    if $actions[pkg]    if $actions[pkg]
349      comment = $actions[pkg].act_comment.gsub(/#\d+/) do |bug|      comment = $actions[pkg].act_comment.gsub(/#\d+/) do |bug|
350        bugn = bug.gsub(/^#/, '')        bugn = bug.gsub(/^#/, '')
# Line 220  res.each do |r| Line 358  res.each do |r|
358  end  end
359  puts "</table>"  puts "</table>"
360    
361  puts " -- #{res.length} packages listed."  tstop = Time::now
362    puts " -- #{res.length} packages listed. Page generated in #{tstop - tstart} seconds. Query took #{tqe - tqs} seconds."
363  puts "</body></html>"  puts "</body></html>"
364    
365    

Legend:
Removed from v.1575  
changed lines
  Added in v.1905

  ViewVC Help
Powered by ViewVC 1.1.5