From 80e765fbe8bf23ba27b5484bdb3a65c7aa723d6f Mon Sep 17 00:00:00 2001 From: "travis%sedsystems.ca" <> Date: Wed, 2 Feb 2005 01:43:26 +0000 Subject: Bug 279740 : Move CountOpenDependencies out of globals.pl Patch by Max Kanat-Alexander r=wurblzap a=justdave --- Bugzilla/Bug.pm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'Bugzilla/Bug.pm') diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index ad48e763f..8f08d8c25 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -536,6 +536,32 @@ sub GetComments { return \@comments; } +# CountOpenDependencies counts the number of open dependent bugs for a +# list of bugs and returns a list of bug_id's and their dependency count +# It takes one parameter: +# - A list of bug numbers whose dependencies are to be checked +sub CountOpenDependencies { + my (@bug_list) = @_; + my @dependencies; + my $dbh = Bugzilla->dbh; + + my $sth = $dbh->prepare( + "SELECT blocked, count(bug_status) " . + "FROM bugs, dependencies " . + "WHERE blocked IN (" . (join "," , @bug_list) . ") " . + "AND bug_id = dependson " . + "AND bug_status IN ('" . (join "','", &::OpenStates()) . "') " . + "GROUP BY blocked "); + $sth->execute(); + + while (my ($bug_id, $dependencies) = $sth->fetchrow_array()) { + push(@dependencies, { bug_id => $bug_id, + dependencies => $dependencies }); + } + + return @dependencies; +} + sub AUTOLOAD { use vars qw($AUTOLOAD); my $attr = $AUTOLOAD; -- cgit v1.2.3-24-g4f1b