From: Kurt Roeckx Date: Mon, 14 Sep 2009 20:38:56 +0000 (+0000) Subject: Make list use state field in the sql select. X-Git-Url: https://git.donarmstrong.com/?p=wannabuild.git;a=commitdiff_plain;h=997b6600e6c8c451cdb23a3c58afd68a22ed5262 Make list use state field in the sql select. The database can filter alot faster than perl, and even has an index for it. --- diff --git a/bin/wanna-build b/bin/wanna-build index debcca4..a079c29 100755 --- a/bin/wanna-build +++ b/bin/wanna-build @@ -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;