#!/usr/bin/ruby -w # Closes old RFP # Always wait for UDD to be updated before running again! require 'pp' require 'dbi' rfp_months = 18 really_mail = true #### old RFP dbh = DBI::connect('DBI:Pg:dbname=udd;port=5441;host=localhost', 'guest') sth = dbh.prepare("select id, arrival, owner, title, last_modified from bugs where package='wnpp' and title ~ 'RFP:' and last_modified < current_date - interval '#{rfp_months} months' and done = '' and id not in (select id from bugs_merged_with where id > merged_with)") sth.execute ; rows = sth.fetch_all rows.each do |r| id = r['id'] subject = r['title'] next if subject !~ /^RFP: ([^ ]+) / source = $1 f = File::new('tmpfile', 'w') puts "#{id}..." f.puts <<-EOF From: Lucas Nussbaum To: #{id}-done@bugs.debian.org Subject: #{source}: closing old inactive RFP Hello, This is an automatic mail sent to close this RFP. Your RFP wnpp bug is being closed because of the following reasons: - It hasn't seen any activity for the last #{rfp_months} months. - The amount of RFPs on the Debian BTS is huge and we need to clean up a bit the place. As this an automatic procedure, it could of course have something wrong and probably it would be closing some bugs that are not intended by owners and submitters to be closed, for example if the RFP is still of your interest, or there has been some kind of activity around it. In that case, please do not hesitate to reopen the bug! To re-open it, you simply have to mail control@bugs.debian.org with a body text like this: reopen #{id} thanks The subject of the mail is ignored. Or if you have any kind of problems when dealing with the BTS, feel free to contact me and I'd be more than happy to help you on this: . Thanks for your cooperation, -- Lucas, for the QA team EOF f.close if really_mail raise "sendmail failed for #{source}!" if not system("/usr/sbin/sendmail -t < tmpfile") end end puts "old RFP: #{rows.length} packages processed"