Author: neronus-guest
Date: 2008-07-29 14:01:16 +0000 (Tue, 29 Jul 2008)
New Revision: 971

Modified:
   udd/src/udd/bugs_gatherer.pl
Log:
Now all bugs which are going to be inserted, are deleted prior to that,
        not only bugs which are archived/unarchived


Modified: udd/src/udd/bugs_gatherer.pl
===================================================================
--- udd/src/udd/bugs_gatherer.pl        2008-07-29 13:59:40 UTC (rev 970)
+++ udd/src/udd/bugs_gatherer.pl        2008-07-29 14:01:16 UTC (rev 971)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# Last-Modified: <Mon Jul 28 23:38:37 2008>
+# Last-Modified: <Tue Jul 29 13:55:14 2008>
 
 use strict;
 use warnings;
@@ -14,22 +14,12 @@
 
 use Debbugs::Bugs qw{get_bugs};
 use Debbugs::Status qw{read_bug get_bug_status bug_presence};
-use Debbugs::Packages qw{binarytosource getpkgsrc};
+use Debbugs::Packages qw{binarytosource};
 use Debbugs::Config qw{:globals};
 use Debbugs::User qw{read_usertags};
 
-use POSIX qw{strftime};
-use Time::Local qw{timelocal};
-
 $YAML::Syck::ImplicitTyping = 1;
 
-sub parse_time {
-       if(shift =~ /(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/) {
-               return ($1, $2, $3, $4, $5, $6);
-       }
-       return undef;
-}
-
 # Return the list of usernames
 sub get_bugs_users {
        my $topdir = "$gSpoolDir/user";
@@ -46,11 +36,6 @@
        return @ret;
 }
 
-sub is_bug_in_db {
-       my ($dbh, $bug_nr) = @_;
-       return $dbh->execute("SELECT * FROM bugs WHERE id = 
$bug_nr")->fetchrow_array();
-}
-
 sub main {
        if(@ARGV != 2) {
                print STDERR "Usage: $0 <config> <source>";
@@ -70,7 +55,8 @@
        # Free usertags table
        $dbh->prepare("DELETE FROM bug_user_tags")->execute() or die
                "Couldn't empty bug_user_tags: $!";
-       # read user tags
+
+       # read and insert user tags
        my @users = get_bugs_users();
        foreach my $user (@users) {
                my %tags = ();
@@ -82,17 +68,22 @@
                }
        }
 
-       #delete the bug from the other tables, if it exists
+       #Get the bugs we want to import
+       my @bugs = $src_config{archived} ? get_bugs(archive => 1) : get_bugs();
+
+       # Delete all bugs we are going to import
        map {
-               $dbh->prepare("DELETE FROM $_ WHERE EXISTS (SELECT * FROM bugs 
WHERE id = bugs.id AND bugs.is_archived = " . ($src_config{archived} ? 'TRUE' : 
'FALSE') . ")")->execute();
-       } qw{bug_found_in bug_fixed_in bug_merged_with};
-       $dbh->prepare("DELETE FROM bugs WHERE is_archived = " . 
($src_config{archived} ? 'TRUE' : 'FALSE'))->execute();
+               $dbh->prepare("DELETE FROM $_ WHERE id IN (" . join(", ", 
@bugs) . ")")->execute()
+                       or die "Could not delete entries from $_: $!";
+       } qw{bugs bug_found_in bug_fixed_in bug_merged_with};
 
+       # Used to chache binary to source mappings
        my %binarytosource = ();
 
+       # XXX What if a bug is in location 'db' (which currently doesn't exist)
        my $location = $src_config{archived} ? 'archive' : 'db_h';
        # Read all bugs
-       foreach my $bug_nr ($src_config{archived} ? get_bugs(archive => 1) : 
get_bugs()) {
+       foreach my $bug_nr (@bugs) {
                #next unless $bug_nr =~ /00$/;
                # Fetch bug using Debbugs
                # Bugs which were once archived and have been unarchived again 
will appear in get_bugs(archive => 1).


_______________________________________________
Collab-qa-commits mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/collab-qa-commits

Reply via email to