Commit 937c6efa authored by Leigh B Stoller's avatar Leigh B Stoller

Add new current/future reservation methods to prediction.

parent 8a87b655
...@@ -1116,6 +1116,7 @@ sub ReservationPrediction($) ...@@ -1116,6 +1116,7 @@ sub ReservationPrediction($)
# clearly no reservations for it. # clearly no reservations for it.
# #
my @projlist = (); my @projlist = ();
my %projlist = ();
foreach my $projurn (@{$projlist}) { foreach my $projurn (@{$projlist}) {
my $project; my $project;
my $hrn = GeniHRN->new($projurn); my $hrn = GeniHRN->new($projurn);
...@@ -1133,14 +1134,17 @@ sub ReservationPrediction($) ...@@ -1133,14 +1134,17 @@ sub ReservationPrediction($)
$project = Project->LookupNonLocal($purn); $project = Project->LookupNonLocal($purn);
} }
next next
if (!defined($project)); if (!defined($project));
$projlist{$project->pid()} = $hrn;
push(@projlist, $project->pid()); push(@projlist, $project->pid());
} }
my $pressure = {}; my $pressure = {};
my $outstanding = {}; my $outstanding = {};
my $freecounts = {}; my $freecounts = {};
my $forecast = {}; my $forecast = {};
my $current = {};
my $upcoming = {};
my @types = Reservation->ReservableTypes(); my @types = Reservation->ReservableTypes();
foreach my $type (@types) { foreach my $type (@types) {
...@@ -1158,10 +1162,14 @@ sub ReservationPrediction($) ...@@ -1158,10 +1162,14 @@ sub ReservationPrediction($)
if (!@pairs); if (!@pairs);
#print STDERR "P: $pid,$type,@pairs\n"; #print STDERR "P: $pid,$type,@pairs\n";
$pressure->{$type}->{$pid} = \@pairs; my $hrn = $projlist{$pid};
my $epid = $hrn->project();
$pressure->{$type}->{$epid} = \@pairs;
} }
} }
foreach my $pid (@projlist) { foreach my $pid (@projlist) {
my $hrn = $projlist{$pid};
my $epid = $hrn->project();
foreach my $type (Reservation->ReservableTypes()) { foreach my $type (Reservation->ReservableTypes()) {
my $type = $type->type(); my $type = $type->type();
my $stamp = Reservation->OutstandingReservation([$pid],[$type]); my $stamp = Reservation->OutstandingReservation([$pid],[$type]);
...@@ -1169,15 +1177,38 @@ sub ReservationPrediction($) ...@@ -1169,15 +1177,38 @@ sub ReservationPrediction($)
if (!$stamp); if (!$stamp);
#print STDERR "O: $pid,$type,$stamp\n"; #print STDERR "O: $pid,$type,$stamp\n";
$outstanding->{$pid}->{$type} = $stamp; $outstanding->{$epid}->{$type} = $stamp;
} }
} }
my @current = Reservation->CurrentReservations(\@projlist);
for my $ref (@current) {
my $pid = $ref->{'pid'};
my $hrn = $projlist{$pid};
my $epid = $hrn->project();
if (!exists($current->{$epid})) {
$current->{$epid} = [];
}
push(@{$current->{$epid}}, $ref)
}
my @upcoming = Reservation->UpcomingReservations(\@projlist);
for my $ref (@upcoming) {
my $pid = $ref->{'pid'};
my $hrn = $projlist{$pid};
my $epid = $hrn->project();
if (!exists($upcoming->{$epid})) {
$upcoming->{$epid} = [];
}
push(@{$upcoming->{$epid}}, $ref)
}
my $blob = { my $blob = {
"freecounts" => $freecounts, "freecounts" => $freecounts,
"forecast" => $forecast, "forecast" => $forecast,
"pressure" => $pressure, "pressure" => $pressure,
"reservations" => $outstanding, "reservations" => $outstanding,
"upcoming" => $upcoming,
"current" => $current,
}; };
#print STDERR Dumper($blob);
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $blob); return GeniResponse->Create(GENIRESPONSE_SUCCESS, $blob);
} }
......
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