* In the last succeeded / job status queries, use the Builds.isCurrent
column instead of Jobs.active.
This commit is contained in:
		| @@ -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: | ||||
|   | ||||
| @@ -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"; | ||||
|   | ||||
| @@ -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; | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -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})]; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -118,7 +118,7 @@ | ||||
|  | ||||
|   <blockquote> | ||||
|     [% IF activeJobs.size == 0 %]<em>(none)</em>[% 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 %] | ||||
|   </blockquote> | ||||
| </p> | ||||
|  | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user