* Job status: show the active jobs.
This commit is contained in:
parent
2ece4d9f15
commit
7c7c43335d
|
@ -10,7 +10,9 @@ use Hydra::Helper::CatalystUtils;
|
||||||
sub jobstatus : Chained('get_builds') PathPart Args(0) {
|
sub jobstatus : Chained('get_builds') PathPart Args(0) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
$c->stash->{template} = 'jobstatus.tt';
|
$c->stash->{template} = 'jobstatus.tt';
|
||||||
$c->stash->{latestBuilds} = getLatestBuilds($c, $c->stash->{allBuilds}, {});
|
my $jobs = $c->stash->{allJobs};
|
||||||
|
$c->stash->{latestBuilds} =
|
||||||
|
getLatestBuilds($c, ref $jobs eq "ARRAY" ? $jobs : scalar $jobs->search({active => 1}), {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +43,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, getLatestBuilds($c, $c->stash->{allBuilds}, {buildStatus => 0}));
|
getChannelData($c, getLatestBuilds($c, scalar $c->stash->{allJobs}->search({active => 1}), {buildStatus => 0}));
|
||||||
}
|
}
|
||||||
elsif ($channelName eq "all") {
|
elsif ($channelName eq "all") {
|
||||||
$c->stash->{channelName} = $c->stash->{channelBaseName} . "-all";
|
$c->stash->{channelName} = $c->stash->{channelBaseName} . "-all";
|
||||||
|
|
|
@ -27,6 +27,9 @@ sub index : Chained('job') PathPart('') Args(0) {
|
||||||
sub get_builds : Chained('job') PathPart('') CaptureArgs(0) {
|
sub get_builds : Chained('job') PathPart('') CaptureArgs(0) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
$c->stash->{allBuilds} = $c->stash->{job}->builds;
|
$c->stash->{allBuilds} = $c->stash->{job}->builds;
|
||||||
|
#$c->stash->{allJobs} = # !!! horribly hacky
|
||||||
|
# $c->stash->{job}->jobset->jobs->search({name => $c->stash->{job}->name});
|
||||||
|
$c->stash->{allJobs} = [$c->stash->{job}];
|
||||||
$c->stash->{channelBaseName} =
|
$c->stash->{channelBaseName} =
|
||||||
$c->stash->{project}->name . "-" . $c->stash->{jobset}->name . "-" . $c->stash->{job}->name;
|
$c->stash->{project}->name . "-" . $c->stash->{jobset}->name . "-" . $c->stash->{job}->name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ sub index : Chained('jobset') PathPart('') Args(0) {
|
||||||
# Hydra::Base::Controller::ListBuilds needs this.
|
# Hydra::Base::Controller::ListBuilds needs this.
|
||||||
sub get_builds : Chained('jobset') PathPart('') CaptureArgs(0) {
|
sub get_builds : Chained('jobset') PathPart('') CaptureArgs(0) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
$c->stash->{allBuilds} =
|
$c->stash->{allBuilds} = $c->stash->{jobset}->builds;
|
||||||
$c->stash->{jobset}->builds;
|
$c->stash->{allJobs} = $c->stash->{jobset}->jobs;
|
||||||
$c->stash->{channelBaseName} =
|
$c->stash->{channelBaseName} =
|
||||||
$c->stash->{project}->name . "-" . $c->stash->{jobset}->name;
|
$c->stash->{project}->name . "-" . $c->stash->{jobset}->name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,6 +225,7 @@ sub updateProject {
|
||||||
sub get_builds : Chained('project') PathPart('') CaptureArgs(0) {
|
sub get_builds : Chained('project') PathPart('') CaptureArgs(0) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
$c->stash->{allBuilds} = $c->stash->{project}->builds;
|
$c->stash->{allBuilds} = $c->stash->{project}->builds;
|
||||||
|
$c->stash->{allJobs} = $c->stash->{project}->jobs;
|
||||||
$c->stash->{channelBaseName} = $c->stash->{project}->name;
|
$c->stash->{channelBaseName} = $c->stash->{project}->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,7 @@ sub release :Local {
|
||||||
sub get_builds : Chained('/') PathPart('') CaptureArgs(0) {
|
sub get_builds : Chained('/') PathPart('') CaptureArgs(0) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
$c->stash->{allBuilds} = $c->model('DB::Builds');
|
$c->stash->{allBuilds} = $c->model('DB::Builds');
|
||||||
|
$c->stash->{allJobs} = $c->model('DB::Jobs');
|
||||||
$c->stash->{channelBaseName} = "everything";
|
$c->stash->{channelBaseName} = "everything";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,23 +45,20 @@ sub getBuildStats {
|
||||||
|
|
||||||
# Return the latest build for each job.
|
# Return the latest build for each job.
|
||||||
sub getLatestBuilds {
|
sub getLatestBuilds {
|
||||||
my ($c, $builds, $extraAttrs) = @_;
|
my ($c, $jobs, $extraAttrs) = @_;
|
||||||
|
|
||||||
my @res = ();
|
my @res = ();
|
||||||
|
|
||||||
foreach my $build ($builds->search({},
|
# !!! this could be done more efficiently.
|
||||||
{group_by => ['project', 'job', 'system']}))
|
|
||||||
{
|
foreach my $job (ref $jobs eq "ARRAY" ? @{$jobs} : $jobs->all) {
|
||||||
my $attrs =
|
foreach my $system ($job->builds->search({}, {select => ['system'], distinct => 1})) {
|
||||||
{ project => $build->get_column('project')
|
my ($build) = $job->builds->search(
|
||||||
, job => $build->get_column('job')
|
{ finished => 1, system => $system->system, %$extraAttrs },
|
||||||
, system => $build->system
|
{ join => 'resultInfo', order_by => 'timestamp DESC', rows => 1 });
|
||||||
, finished => 1
|
|
||||||
};
|
|
||||||
my ($build) = $builds->search({ %$attrs, %$extraAttrs },
|
|
||||||
{ join => 'resultInfo', order_by => 'timestamp DESC', rows => 1 } );
|
|
||||||
push @res, $build if defined $build;
|
push @res, $build if defined $build;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return [@res];
|
return [@res];
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,7 +355,6 @@ sub checkJobSet {
|
||||||
|
|
||||||
$db->txn_do(sub {
|
$db->txn_do(sub {
|
||||||
foreach my $jobInDB ($jobset->jobs->all) {
|
foreach my $jobInDB ($jobset->jobs->all) {
|
||||||
print $jobInDB->name, "\n";
|
|
||||||
$jobInDB->update({active => $jobNames{$jobInDB->name} || $failedJobNames{$jobInDB->name} ? 1 : 0});
|
$jobInDB->update({active => $jobNames{$jobInDB->name} || $failedJobNames{$jobInDB->name} ? 1 : 0});
|
||||||
|
|
||||||
if ($failedJobNames{$jobInDB->name}) {
|
if ($failedJobNames{$jobInDB->name}) {
|
||||||
|
|
Loading…
Reference in a new issue