]> git.donarmstrong.com Git - wannabuild.git/commitdiff
Make list use state field in the sql select.
authorKurt Roeckx <kurt@roeckx.be>
Mon, 14 Sep 2009 20:38:56 +0000 (20:38 +0000)
committerKurt Roeckx <kurt@roeckx.be>
Mon, 14 Sep 2009 20:38:56 +0000 (20:38 +0000)
The database can filter alot faster than perl, and even has an index for it.

bin/wanna-build

index debcca4db55e1008368d601638b658cce6f71c4b..a079c295da46adf4df777a8c46d63a88382c101d 100755 (executable)
@@ -1759,12 +1759,16 @@ sub list_packages {
        my $cnt = 0;
        my %scnt;
        my $ctime = time;
+       my $db;
 
-       my $db = get_all_source_info();
+       if ($state ne "all") {
+               $db = get_all_source_info_state($state);
+       } else {
+               $db = get_all_source_info();
+       }
        foreach $name (keys %$db) {
                next if $name =~ /^_/;
                $pkg = $db->{$name};
-               next if $state ne "all" && $pkg->{'state'} !~ /^\Q$state\E$/i;
                next if $user && (lc($state) ne 'needs-build' and $pkg->{'builder'} ne $user);
                next if $category && $pkg->{'state'} eq "Failed" &&
                                $pkg->{'failed_category'} ne $category;
@@ -2441,6 +2445,14 @@ sub get_all_source_info {
        return $db;
 }
 
+sub get_all_source_info_state {
+       my $state = shift;
+       my $db = $dbh->selectall_hashref('SELECT * FROM ' . table_name() .
+               ' WHERE distribution = ? and state = ?',
+               'package', undef, $distribution, $state);
+       return $db;
+}
+
 sub update_source_info {
        my $pkg = shift;