Commit dbb97d05 authored by Leigh Stoller's avatar Leigh Stoller

Add function get project inuse count for a specific type.

parent 879fc245
......@@ -1076,5 +1076,25 @@ sub Usage($$$)
return \@summary;
}
#
# Return count of how many nodes of a type in use.
#
sub TypeInUseCount($$)
{
my ($self, $type) = @_;
my $pid = $self->pid();
my $result =
DBQueryWarn("select count(n.type) from reserved as r ".
"left join nodes as n on n.node_id=r.node_id ".
"where pid='$pid' and type='$type' ".
"group by type");
return 0
if (!defined($result) || !$result->numrows);
my ($count) = $result->fetchrow_array();
return $count;
}
# _Always_ make sure that this 1 is at the end of the file...
1;
......@@ -1097,18 +1097,7 @@ sub Reservations($)
next;
}
if (!exists($current{"$pid:$type"})) {
$current{"$pid:$type"} = 0;
my $result =
DBQueryWarn("select count(n.type) from reserved as r ".
"left join nodes as n on n.node_id=r.node_id ".
"where pid='$pid' and type='$type' ".
"group by type");
if ($result && $result->numrows) {
my ($count) = $result->fetchrow_array();
$current{"$pid:$type"} = $count;
}
$current{"$pid:$type"} = $project->TypeInUseCount($type);
}
if (time() > $row->{'start'}) {
$using = $current{"$pid:$type"};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment