From ec87ad2bf234e4d480aa674eef9bf5b2d89f3903 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 15 Apr 2012 22:57:10 +0000 Subject: [PATCH] Missing part of aaacf9eda36f5cdcc77cec20d6f49fbb6f925105 --- src/lib/Hydra/Controller/Jobset.pm | 17 ++++++++++++----- src/lib/Hydra/Schema/JobsetEvals.pm | 18 ++++++++++++++++-- src/script/hydra-evaluator | 1 + src/sql/hydra.sql | 4 ++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 5b105786..4dc90094 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -339,9 +339,17 @@ sub getEvals { my $cur = $evals[$n]; # Get stats for this eval. - my $nrBuilds = $cur->jobsetevalmembers->count; - my $nrScheduled = $cur->builds->search({finished => 0})->count; - my $nrSucceeded = $cur->builds->search({finished => 1, buildStatus => 0})->count; + my $nrScheduled; + my $nrSucceeded = $cur->nrsucceeded; + if (defined $nrSucceeded) { + $nrScheduled = 0; + } else { + $nrScheduled = $cur->builds->search({finished => 0})->count; + $nrSucceeded = $cur->builds->search({finished => 1, buildStatus => 0})->count; + if ($nrScheduled == 0) { + $cur->update({nrsucceeded => $nrSucceeded}); + } + } # Compute what inputs changed between each eval. my $curInputs = [ $cur->jobsetevalinputs->search( @@ -359,10 +367,9 @@ sub getEvals { my $e = { eval => $cur - , nrBuilds => $nrBuilds , nrScheduled => $nrScheduled , nrSucceeded => $nrSucceeded - , nrFailed => $nrBuilds - $nrSucceeded - $nrScheduled + , nrFailed => $cur->nrbuilds - $nrSucceeded - $nrScheduled , diff => defined $prev ? $nrSucceeded - $prev->{nrSucceeded} : 0 , changedInputs => [ @changedInputs ] }; diff --git a/src/lib/Hydra/Schema/JobsetEvals.pm b/src/lib/Hydra/Schema/JobsetEvals.pm index 3dc74525..df5fa673 100644 --- a/src/lib/Hydra/Schema/JobsetEvals.pm +++ b/src/lib/Hydra/Schema/JobsetEvals.pm @@ -66,6 +66,16 @@ __PACKAGE__->table("JobsetEvals"); data_type: 'text' is_nullable: 0 +=head2 nrbuilds + + data_type: 'integer' + is_nullable: 1 + +=head2 nrsucceeded + + data_type: 'integer' + is_nullable: 1 + =cut __PACKAGE__->add_columns( @@ -85,6 +95,10 @@ __PACKAGE__->add_columns( { data_type => "integer", is_nullable => 0 }, "hash", { data_type => "text", is_nullable => 0 }, + "nrbuilds", + { data_type => "integer", is_nullable => 1 }, + "nrsucceeded", + { data_type => "integer", is_nullable => 1 }, ); =head1 PRIMARY KEY @@ -157,8 +171,8 @@ Related object: L __PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }, {}); -# Created by DBIx::Class::Schema::Loader v0.07014 @ 2012-04-15 16:38:10 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Yt39QbkhH52hfpJZ4ZECeg +# Created by DBIx::Class::Schema::Loader v0.07014 @ 2012-04-15 22:30:41 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jn81MbsAb5KZGwRpQ7qTEQ __PACKAGE__->has_many( "buildIds", diff --git a/src/script/hydra-evaluator b/src/script/hydra-evaluator index 22f34de6..7e3fac60 100755 --- a/src/script/hydra-evaluator +++ b/src/script/hydra-evaluator @@ -165,6 +165,7 @@ sub checkJobset { , checkouttime => abs($checkoutStop - $checkoutStart) , evaltime => abs($evalStop - $evalStart) , hasnewbuilds => $hasNewBuilds + , nrbuilds => $hasNewBuilds ? scalar(keys %buildIds) : undef }); if ($hasNewBuilds) { diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 485e3315..ebe2e429 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -438,6 +438,10 @@ create table JobsetEvals ( -- over the command-line arguments to hydra-eval-jobs. hash text not null, + -- Cached stats about the builds. + nrBuilds integer, + nrSucceeded integer, -- set lazily when all builds are finished + foreign key (project) references Projects(name) on delete cascade on update cascade, foreign key (project, jobset) references Jobsets(project, name) on delete cascade on update cascade );