Commit 9387829b authored by Leigh Stoller's avatar Leigh Stoller

Minor changes for handling reservations that are deleted before they

expire, now that we store that info in the history table.
parent 5d264a32
......@@ -1156,6 +1156,10 @@ sub DoHistory()
$res->{'cancel'} eq "") {
$res->{'cancel'} = undef;
}
if (!exists($res->{'deleted'}) ||
$res->{'deleted'} eq "") {
$res->{'deleted'} = undef;
}
if (!exists($res->{'uuid'}) ||
$res->{'uuid'} eq "") {
$res->{'uuid'} = NewUUID();
......
......@@ -99,7 +99,17 @@ sub CreateTimeline($@)
# We want to bound the end of the search to the latest end if we
# have only historial reservations.
#
my @tmp = sort {$a->end() <=> $b->end()} @reservations;
# We have to watch for reservations that are deleted before they
# expire; that is the actual end time for the reservation.
#
my $sortfunc = sub {
my $a = $_[0];
my $b = $_[1];
my $s1 = (defined($a->deleted()) ? $a->deleted() : $a->end());
my $s2 = (defined($b->deleted()) ? $b->deleted() : $b->end());
return $s1 <=> $s2;
};
my @tmp = sort $sortfunc @reservations;
my $latest = $tmp[-1];
if ($debug) {
print "The latest reservation end is " .
......
......@@ -216,6 +216,8 @@ sub Lookup($$;$$$$)
$self->{'APPROVED'} = $record->{'a'};
$self->{'APPROVER'} = $record->{'approver'};
$self->{'UUID'} = $record->{'uuid'};
# For compat with history entries.
$self->{'DELETED'} = undef;
bless($self, $class);
......@@ -239,6 +241,8 @@ sub admin_notes($) { return $_[0]->{"ADMIN_NOTES"}; }
sub approved($) { return $_[0]->{"APPROVED"}; }
sub approver($) { return $_[0]->{"APPROVER"}; }
sub uuid($) { return $_[0]->{"UUID"}; }
# For compat with history entries.
sub deleted($) { return $_[0]->{"DELETED"}; }
sub Stringify($)
{
......@@ -1283,7 +1287,6 @@ sub HistoricalReservations($$$;$) {
}
return @answer;
}
sub deleted($) { return $_[0]->{"DELETED"}; }
sub ExptTypes($) {
my ($exptidx) = @_;
......
......@@ -162,7 +162,14 @@
<span class="format-date"><%- value.start %></span>
<% } %>
</td>
<td class="format-date"><%- value.end %></td>
<td>
<% if (_.has(value, "deleted") && value.deleted) { %>
<span class="format-date"
style="color: red;"><%- value.deleted %></span>
<% } else { %>
<span class="format-date"><%- value.end %></span>
<% } %>
</td>
<% if (showusing) { %>
<td class="status-column">
<span class="status-approved hidden">Approved</span>
......
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