/[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

revision 1550 by lucas, Thu Jul 30 00:17:20 2009 UTC revision 1598 by lucas, Wed Oct 7 19:55:23 2009 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    class Actions
6      attr_reader :actions, :act_todo, :act_status, :act_comment
7      def initialize
8        @actions = []
9        @act_status = ""
10        @act_todo = false
11        @act_comment = ""
12      end
13    
14      def add(desc)
15        desc.chomp!
16        date, who, act, comment = desc.split(' ', 4)
17        date = Date::parse(date)
18        if act =~ /^(.+)\((.+)\)$/
19          act_name, act_arg = $1, $2
20          if [ 'PROP_RM', 'PROP_RM_O', 'PROP_O', 'O', 'REQ_RM', 'RM', 'SEC_RM', 'O_PROP_RM' ].include?(act_name)
21            # FIXME check bug
22          elsif act_name == 'WAIT'
23            act_arg = act_arg.to_i
24          else
25            puts "Unknown action: #{act} (#{desc})"
26          end
27          @actions << [date, who, [act_name, act_arg], comment]
28        elsif act == 'OK'
29          act_name = 'OK'
30          act_arg = nil
31          @actions << [date, who, [act_name, act_arg], comment]
32        else
33          puts "Unparseable action: #{act} (#{desc})"
34          exit(1)
35        end
36      end
37    
38      def analyze_actions
39        @actions.sort! { |a,b| b[0] <=> a[0] }
40        idx = 0
41        rm_o = false
42        while idx < @actions.length
43          if @actions[idx][2][0] == 'OK'
44            @act_status = ""
45            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
46            break
47          elsif @actions[idx][2][0] == 'WAIT'
48            if @actions[idx][0] + @actions[idx][2][1] <= CURDATE
49              idx += 1
50              next # OK not valid anymore, consider next action
51            else
52              # nothing to do except waiting
53              @act_status = "Waiting until #{@actions[idx][0] + @actions[idx][2][1]}"
54              @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
55              break
56            end
57          elsif @actions[idx][2][0] == 'REQ_RM' or @actions[idx][2][0] == 'RM'
58            @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Removal was requested</a>"
59            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
60            break
61          elsif @actions[idx][2][0] == 'O'
62            @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Was orphaned</a>"
63            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
64            break
65          elsif @actions[idx][2][0] == 'PROP_RM_O'
66            @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Was orphaned, will need removal</a>"
67            rm_o = true
68            idx += 1
69            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
70            next
71          elsif @actions[idx][2][0] == 'PROP_RM'
72            ok = false
73            if @actions[idx][0] + WAIT_RM_O <= CURDATE and !rm_o
74              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Should be orphaned before removal (since #{@actions[idx][0] + 50})</a>"
75              @act_todo = true
76              ok = true
77            end
78            if @actions[idx][0] + WAIT_RM_RM <= CURDATE
79              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Should be removed (since #{@actions[idx][0] + 100})</a>"
80              @act_todo = true
81              ok = true
82            end
83            if !ok
84              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Removal suggested (since #{@actions[idx][0]})</a>"
85            end
86            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
87            break
88          elsif @actions[idx][2][0] == 'PROP_O'
89            if @actions[idx][0] + WAIT_O_O <= CURDATE
90              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Should be orphaned (since #{@actions[idx][0] + 50})</a>"
91              @act_todo = true
92            else
93              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Orphaning suggested (since #{@actions[idx][0]})</a>"
94            end
95            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
96            break
97          elsif @actions[idx][2][0] == 'O_PROP_RM'
98            if @actions[idx][0] + WAIT_ORM_RM <= CURDATE
99              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Should be removed (O pkg) (since #{@actions[idx][0] + 50})</a>"
100              @act_todo = true
101            else
102              @act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Removal suggested (O pkg) (since #{@actions[idx][0]})</a>"
103            end
104            @act_comment = @actions[idx][3] if not @actions[idx][3].nil?
105            break
106          else
107            puts "Unknown act: #{@actions[idx][2][0]}"
108          end
109        end
110      end
111    
112      def Actions::fetch
113        d = IO::popen("svn cat svn://svn.debian.org/collab-qa/bapase/package-actions.txt")
114        f = d.read
115        d.close
116        return Actions::read(f)
117      end
118    
119      def Actions::read(data)
120        pkgs = {}
121        data.each_line do |l|
122          next if l =~/^\s*#/ or l =~/^\s*$/
123          pkg, rest = l.split(' ',2)
124          if pkgs[pkg].nil?
125            pkgs[pkg] = Actions::new
126          end
127          pkgs[pkg].add(rest)
128        end
129        pkgs.each_pair { |k, v| v.analyze_actions }
130      end
131    end
132    
133  puts "Content-type: text/html\n\n"  puts "Content-type: text/html\n\n"
134    
# Line 29  elsif type == 'nmu' Line 156  elsif type == 'nmu'
156    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"
157  elsif type == 'testing'  elsif type == 'testing'
158    orphaned = true    orphaned = true
159    query = "select * from bapase where testing_age > 1 order by testing_age desc"    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"
160    elsif type == 'nodd'
161      orphaned = true
162      query = <<EOF
163    select * from bapase where source in (
164    SELECT source
165    FROM sources
166    WHERE distribution = 'debian' AND release = 'sid'
167    AND sources.source NOT IN (
168    SELECT sources.source
169    FROM sources
170    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)
171    WHERE sources.distribution = 'debian' AND sources.release = 'sid'
172    AND (maintainer_email in (SELECT email FROM carnivore_emails, active_dds WHERE active_dds.id = carnivore_emails.id)
173    OR email in (SELECT email FROM carnivore_emails, active_dds WHERE active_dds.id = carnivore_emails.id)
174    OR maintainer_email ~ '.*@lists.(alioth.)?debian.org'
175    OR email ~ '.*@lists.(alioth.)?debian.org'))
176    ) order by upload_age desc
177    EOF
178    elsif type == 'maintnmu'
179      orphaned = true
180      query = <<EOF
181    select * from bapase where source in (
182      select source from sources where distribution='debian' and release='squeeze' and maintainer_email in (
183    select nmus.email from
184    (select email, count(*) as tot from
185    (select maintainer_email as email, source from sources
186    where release = 'sid'
187    and distribution = 'debian'
188    and component = 'main'
189    union
190    select email, source from uploaders
191    where release = 'sid'
192    and distribution = 'debian'
193    and component = 'main') as foo
194    group by email) as tot,
195    (select email, count(*) as nmus from
196    (select sources.maintainer_email as email, sources.source from sources, upload_history uh
197    where release = 'sid'
198    and distribution = 'debian'
199    and component = 'main'
200    and sources.source = uh.source and sources.version = uh.version
201    and uh.nmu
202    union
203    select email, uploaders.source from uploaders, upload_history uh
204    where release = 'sid'
205    and distribution = 'debian'
206    and component = 'main'
207    and uploaders.source = uh.source and uploaders.version = uh.version
208    and uh.nmu
209    ) as foo
210    group by email) as nmus
211    where nmus * 100 / tot >= 100
212    and nmus.email = tot.email)
213    union (select source from uploaders where distribution='debian' and release='squeeze' and email in (
214    select nmus.email from
215    (select email, count(*) as tot from
216    (select maintainer_email as email, source from sources
217    where release = 'sid'
218    and distribution = 'debian'
219    and component = 'main'
220    union
221    select email, source from uploaders
222    where release = 'sid'
223    and distribution = 'debian'
224    and component = 'main') as foo
225    group by email) as tot,
226    (select email, count(*) as nmus from
227    (select sources.maintainer_email as email, sources.source from sources, upload_history uh
228    where release = 'sid'
229    and distribution = 'debian'
230    and component = 'main'
231    and sources.source = uh.source and sources.version = uh.version
232    and uh.nmu
233    union
234    select email, uploaders.source from uploaders, upload_history uh
235    where release = 'sid'
236    and distribution = 'debian'
237    and component = 'main'
238    and uploaders.source = uh.source and uploaders.version = uh.version
239    and uh.nmu
240    ) as foo
241    group by email) as nmus
242    where nmus * 100 / tot >= 100
243    and nmus.email = tot.email
244    ))) order by nmus
245    EOF
246  else  else
247    puts <<-EOF    puts <<-EOF
248    <a href="bapase.cgi?t=o">Orphaned packages</a><br/>    <h1>Bapase</h1>
249    <a href="bapase.cgi?t=nmu">Packages maintained with NMUs</a><br/>    <ul>
250    <a href="bapase.cgi?t=testing">Packages not in testing</a><br/>    <li><a href="bapase.cgi?t=o">Orphaned packages</a></li>
251      <li><a href="bapase.cgi?t=nmu">Packages maintained with NMUs</a></li>
252      <li><a href="bapase.cgi?t=testing">Packages not in testing</a></li>
253      <li><a href="bapase.cgi?t=nodd">Packages not maintained by DDs</a></li>
254      <li><a href="bapase.cgi?t=maintnmu">Packages maintained or co-maintained by people with lots of NMUs</a></li>
255      </ul>
256    </body></html>    </body></html>
257    EOF    EOF
258    exit(0)    exit(0)

Legend:
Removed from v.1550  
changed lines
  Added in v.1598

  ViewVC Help
Powered by ViewVC 1.1.5