diff --git a/doc/dev-notes.txt b/doc/dev-notes.txt index 1471865b..42ef2d49 100644 --- a/doc/dev-notes.txt +++ b/doc/dev-notes.txt @@ -90,7 +90,9 @@ alter table jobs add column disabled integer not null default 0; alter table builds add column maintainers text; + # Add the isCurrent column to Builds and use the obsolete Jobs.active to fill it in. alter table builds add column isCurrent integer default 0; + update builds set isCurrent = 1 where id in (select max(id) from builds natural join (select distinct b.project, b.jobset, b.job, b.system from builds b join (select project, jobset, name from jobs where active = 1) j on b.project = j.project and b.jobset = j.jobset and b.job = j.name) b2 group by project, jobset, job, system); * Job selection: diff --git a/src/lib/Hydra/Base/Controller/ListBuilds.pm b/src/lib/Hydra/Base/Controller/ListBuilds.pm index e0d12122..e10d45ce 100644 --- a/src/lib/Hydra/Base/Controller/ListBuilds.pm +++ b/src/lib/Hydra/Base/Controller/ListBuilds.pm @@ -7,25 +7,11 @@ use Hydra::Helper::Nix; use Hydra::Helper::CatalystUtils; -sub filterInactiveJobs { - my ($build) = @_; - return $build->search( - { active => 1 }, - { join => 'job' - , '+select' => ["job.active"] - , '+as' => ["active"] - }); -} - - sub getJobStatus { my ($self, $c) = @_; my $latest = joinWithResultInfo($c, $c->stash->{jobStatus}); - $latest = filterInactiveJobs($latest) - unless defined $c->stash->{showInactiveJobs}; - $latest = $latest->search( {}, { '+select' => ["me.statusChangeId", "me.statusChangeTime"] @@ -90,7 +76,7 @@ sub nix : Chained('get_builds') PathPart('channel') CaptureArgs(1) { eval { if ($channelName eq "latest") { $c->stash->{channelName} = $c->stash->{channelBaseName} . "-latest"; - getChannelData($c, scalar(filterInactiveJobs($c->stash->{latestSucceeded}))); + getChannelData($c, scalar($c->stash->{latestSucceeded})); } elsif ($channelName eq "all") { $c->stash->{channelName} = $c->stash->{channelBaseName} . "-all"; diff --git a/src/lib/Hydra/Controller/Job.pm b/src/lib/Hydra/Controller/Job.pm index 9e3014d0..bc88ab31 100644 --- a/src/lib/Hydra/Controller/Job.pm +++ b/src/lib/Hydra/Controller/Job.pm @@ -15,7 +15,6 @@ sub job : Chained('/') PathPart('job') CaptureArgs(3) { or notFound($c, "Job $projectName:$jobsetName:$jobName doesn't exist."); $c->stash->{project} = $c->stash->{job}->project; $c->stash->{jobset} = $c->stash->{job}->jobset; - $c->stash->{showInactiveJobs} = 1; } diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 78d255e1..cd461696 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -28,7 +28,7 @@ sub index : Chained('jobset') PathPart('') Args(0) { getBuildStats($c, scalar $c->stash->{jobset}->builds); - $c->stash->{activeJobs} = [$c->stash->{jobset}->jobs->search({active => 1})]; + $c->stash->{activeJobs} = [$c->stash->{jobset}->builds->search({isCurrent => 1}, {select => ["job"], distinct => 1})]; $c->stash->{inactiveJobs} = [$c->stash->{jobset}->jobs->search({active => 0})]; } diff --git a/src/lib/Hydra/Schema/Builds.pm b/src/lib/Hydra/Schema/Builds.pm index 4907198a..913e96d3 100644 --- a/src/lib/Hydra/Schema/Builds.pm +++ b/src/lib/Hydra/Schema/Builds.pm @@ -227,6 +227,8 @@ sub makeQueries { (r.buildstatus != 0 and r2.buildstatus = 0))) QUERY + my $activeJobs = "(select distinct project, jobset, job, system from Builds where isCurrent = 1 $constraint)"; + makeSource( "JobStatus$name", # Urgh, can't use "*" in the "select" here because of the status change join. @@ -238,7 +240,10 @@ QUERY b.id as statusChangeId, b.timestamp as statusChangeTime from (select project, jobset, job, system, max(id) as id - from Builds where finished = 1 $constraint group by project, jobset, job, system) + from $activeJobs as activeJobs + natural join Builds + where finished = 1 + group by project, jobset, job, system) as latest natural join Builds x $joinWithStatusChange @@ -251,8 +256,10 @@ QUERY select * from (select project, jobset, job, system, max(id) as id - from Builds natural join BuildResultInfo - where finished = 1 and buildStatus = 0 $constraint + from $activeJobs as activeJobs + natural join Builds + natural join BuildResultInfo + where finished = 1 and buildStatus = 0 group by project, jobset, job, system ) as latest natural join Builds diff --git a/src/root/jobset.tt b/src/root/jobset.tt index 41342239..07c6f543 100644 --- a/src/root/jobset.tt +++ b/src/root/jobset.tt @@ -118,7 +118,7 @@
[% IF activeJobs.size == 0 %](none)[% END %] - [% FOREACH j IN activeJobs %] [% INCLUDE renderJobName project=project.name jobset=jobset.name job=j.name %] [% END %] + [% FOREACH j IN activeJobs %] [% INCLUDE renderJobName project=project.name jobset=jobset.name job=j.get_column('job') %] [% END %]diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 285dac8c..24a90334 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -410,6 +410,7 @@ create index IndexBuildInputsByBuild on BuildInputs(build); create index IndexBuildInputsByDependency on BuildInputs(dependency); create index IndexBuildsByTimestamp on Builds(timestamp); create index IndexBuildsByJobAndSystem on Builds(project, jobset, job, system); +create index IndexBuildsByIsCurrent on Builds(isCurrent); create index IndexBuildResultInfo on BuildResultInfo(id); -- primary key index, not created automatically by PostgreSQL create index IndexBuild on BuildProducts(build); create index IndexBuildType on BuildProducts(build, type);