#---------- duration estimator ----------
-sub duration_estimator ($$;$) {
- my ($branch, $blessing, $debug) = @_;
+sub duration_estimator ($$;$$) {
+ my ($branch, $blessing, $debug, $will_uptoincl_testid) = @_;
# returns a function which you call like this
- # $durest->($job, $hostidname, $onhost)
+ # $durest->($job, $hostidname, $onhost [, $uptoincl_testid])
# and returns one of
# ($seconds, $samehostlaststarttime, $samehostlaststatus)
# ($seconds, undef, undef)
# ()
# $debug should be something like sub { print DEBUG "@_\n"; }.
# Pass '' for $hostidname and $onhost for asking about on any host
+ #
+ # $uptincl_testid must be passed iff $will_uptoincl_testid, in
+ # which case the duration up to and including that step will be
+ # estimated (and only jobs which contained that step will be
+ # considered).
my $recentflights_q= $dbh_tests->prepare(<<END);
SELECT f.flight AS flight,
FROM tsteps
WHERE step != 'ts-hosts-allocate'
END
+
+ if ($will_uptoincl_testid) {
+ $duration_duration_qtxt .= <<END;
+ AND finished <=
+ (SELECT finished
+ FROM tsteps
+ WHERE tsteps.testid = ?)
+END
+ }
my $duration_duration_q = $dbh_tests->prepare($duration_duration_qtxt);
return sub {
- my ($job, $hostidname, $onhost) = @_;
+ my ($job, $hostidname, $onhost, $uptoincl_testid) = @_;
my $dbg= $debug ? sub {
$debug->("DUR $branch $blessing $job $hostidname $onhost @_");
my $duration_max= 0;
foreach my $ref (@$refs) {
my @d_d_args = ($ref->{flight}, $job);
+ push @d_d_args, $uptoincl_testid if $will_uptoincl_testid;
$duration_duration_q->execute(@d_d_args);
my ($duration) = $duration_duration_q->fetchrow_array();
$duration_duration_q->finish();