* In the last succeeded / job status queries, use the Builds.isCurrent

column instead of Jobs.active.
This commit is contained in:
Eelco Dolstra 2009-10-07 15:45:17 +00:00
parent 48d8871dbc
commit 16f2d003b2
7 changed files with 16 additions and 21 deletions

View file

@ -90,7 +90,9 @@
alter table jobs add column disabled integer not null default 0; alter table jobs add column disabled integer not null default 0;
alter table builds add column maintainers text; 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; 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: * Job selection:

View file

@ -7,25 +7,11 @@ use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils; use Hydra::Helper::CatalystUtils;
sub filterInactiveJobs {
my ($build) = @_;
return $build->search(
{ active => 1 },
{ join => 'job'
, '+select' => ["job.active"]
, '+as' => ["active"]
});
}
sub getJobStatus { sub getJobStatus {
my ($self, $c) = @_; my ($self, $c) = @_;
my $latest = joinWithResultInfo($c, $c->stash->{jobStatus}); my $latest = joinWithResultInfo($c, $c->stash->{jobStatus});
$latest = filterInactiveJobs($latest)
unless defined $c->stash->{showInactiveJobs};
$latest = $latest->search( $latest = $latest->search(
{}, {},
{ '+select' => ["me.statusChangeId", "me.statusChangeTime"] { '+select' => ["me.statusChangeId", "me.statusChangeTime"]
@ -90,7 +76,7 @@ sub nix : Chained('get_builds') PathPart('channel') CaptureArgs(1) {
eval { eval {
if ($channelName eq "latest") { if ($channelName eq "latest") {
$c->stash->{channelName} = $c->stash->{channelBaseName} . "-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") { elsif ($channelName eq "all") {
$c->stash->{channelName} = $c->stash->{channelBaseName} . "-all"; $c->stash->{channelName} = $c->stash->{channelBaseName} . "-all";

View file

@ -15,7 +15,6 @@ sub job : Chained('/') PathPart('job') CaptureArgs(3) {
or notFound($c, "Job $projectName:$jobsetName:$jobName doesn't exist."); or notFound($c, "Job $projectName:$jobsetName:$jobName doesn't exist.");
$c->stash->{project} = $c->stash->{job}->project; $c->stash->{project} = $c->stash->{job}->project;
$c->stash->{jobset} = $c->stash->{job}->jobset; $c->stash->{jobset} = $c->stash->{job}->jobset;
$c->stash->{showInactiveJobs} = 1;
} }

View file

@ -28,7 +28,7 @@ sub index : Chained('jobset') PathPart('') Args(0) {
getBuildStats($c, scalar $c->stash->{jobset}->builds); 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})]; $c->stash->{inactiveJobs} = [$c->stash->{jobset}->jobs->search({active => 0})];
} }

View file

@ -227,6 +227,8 @@ sub makeQueries {
(r.buildstatus != 0 and r2.buildstatus = 0))) (r.buildstatus != 0 and r2.buildstatus = 0)))
QUERY QUERY
my $activeJobs = "(select distinct project, jobset, job, system from Builds where isCurrent = 1 $constraint)";
makeSource( makeSource(
"JobStatus$name", "JobStatus$name",
# Urgh, can't use "*" in the "select" here because of the status change join. # 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 b.id as statusChangeId, b.timestamp as statusChangeTime
from from
(select project, jobset, job, system, max(id) as id (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 as latest
natural join Builds x natural join Builds x
$joinWithStatusChange $joinWithStatusChange
@ -251,8 +256,10 @@ QUERY
select * select *
from from
(select project, jobset, job, system, max(id) as id (select project, jobset, job, system, max(id) as id
from Builds natural join BuildResultInfo from $activeJobs as activeJobs
where finished = 1 and buildStatus = 0 $constraint natural join Builds
natural join BuildResultInfo
where finished = 1 and buildStatus = 0
group by project, jobset, job, system group by project, jobset, job, system
) as latest ) as latest
natural join Builds natural join Builds

View file

@ -118,7 +118,7 @@
<blockquote> <blockquote>
[% IF activeJobs.size == 0 %]<em>(none)</em>[% END %] [% 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> </blockquote>
</p> </p>

View file

@ -410,6 +410,7 @@ create index IndexBuildInputsByBuild on BuildInputs(build);
create index IndexBuildInputsByDependency on BuildInputs(dependency); create index IndexBuildInputsByDependency on BuildInputs(dependency);
create index IndexBuildsByTimestamp on Builds(timestamp); create index IndexBuildsByTimestamp on Builds(timestamp);
create index IndexBuildsByJobAndSystem on Builds(project, jobset, job, system); 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 IndexBuildResultInfo on BuildResultInfo(id); -- primary key index, not created automatically by PostgreSQL
create index IndexBuild on BuildProducts(build); create index IndexBuild on BuildProducts(build);
create index IndexBuildType on BuildProducts(build, type); create index IndexBuildType on BuildProducts(build, type);