+sub GetStorage($$$;$$$$$) {
+ my ($self, $type, $tag, $storage, $region, $start, $end, $count, $interval) = @_;
+
+ $interval ||= 'Day';
+ $region ||= $Clearcase::CC->region;
+
+ return unless $type =~ /vob/i or $type =~ /view/;
+
+ my $size = $interval =~ /month/i
+ ? 7
+ : $interval =~ /day/i
+ ? 10
+ : $interval =~ /hour/i
+ ? 13
+ : 16;
+
+ undef $start if $start and $start =~ /earliest/i;
+ undef $end if $end and $end =~ /latest/i;
+
+ my $condition;
+ my $table = $type eq 'vob' ? 'vobstorage' : 'viewstorage';
+
+ $condition = "tag='$tag' and region='$region'";
+ $condition .= " and timestamp>='$start'" if $start;
+ $condition .= " and timestamp<='$end'" if $end;
+
+ $condition .= " group by left(timestamp,$size)";
+
+ if ($count) {
+ # We can't simply do a "limit 0, $count" as that just gets the front end of
+ # the records return (i.e. if $count = say 10 and the timestamp range
+ # returns 40 rows we'll see only rows 1-10, not rows 31-40). We need limit
+ # $offset, $count where $offset = the number of qualifying records minus
+ # $count
+ my $nbrRecs = $self->Count($table, $condition);
+ my $offset = $nbrRecs - $count;
+
+ # Offsets of < 0 are not allowed.
+ $offset = 0 if $offset < 0;
+
+ $condition .= " limit $offset, $count";
+ } # if
+
+ my $statement = <<"END";
+select
+ tag,
+ region,
+ left(timestamp,$size) as timestamp,
+ avg($storage) as size
+from
+ $table
+ where $condition
+END
+
+ my ($err, $msg);
+
+ my $sth = $self->{db}->prepare($statement);
+
+ unless ($sth) {
+ ($err, $msg) = $self->_dberror('Unable to prepare statement', $statement);
+
+ croak $msg;
+ } # if
+
+ my $status = $sth->execute;
+
+ unless ($status) {
+ ($err, $msg) = $self->_dberror('Unable to execute statement', $statement);
+
+ croak $msg;
+ } # if
+
+ my @records;
+
+ while (my $row = $sth->fetchrow_hashref) {
+ push @records, $row;
+ } # while
+
+ return @records;
+} # GetStorage
+
+sub AddTask(%) {