* Show job status and all builds for a project.

This commit is contained in:
Eelco Dolstra 2008-11-27 02:23:44 +00:00
parent bebd4a8b89
commit ab16bfaf95
4 changed files with 46 additions and 21 deletions

View file

@ -118,42 +118,58 @@ sub queue :Local {
} }
sub jobstatus :Local { sub showJobStatus :Local {
my ($self, $c) = @_; my ($c, $builds) = @_;
$c->stash->{template} = 'jobstatus.tt'; $c->stash->{template} = 'jobstatus.tt';
# Get the latest finished build for each unique job. # Get the latest finished build for each unique job.
$c->stash->{latestBuilds} = [$c->model('DB::Builds')->search(undef, $c->stash->{latestBuilds} = [$builds->search({},
{ join => 'resultInfo' { join => 'resultInfo'
, where => "finished != 0 and timestamp = (select max(timestamp) from Builds " . , where => {
"where project == me.project and attrName == me.attrName and finished != 0 and system == me.system)" finished => { "!=", 0 },
timestamp => \ (
"= (select max(timestamp) from Builds " .
"where project == me.project and attrName == me.attrName and finished != 0 and system == me.system)"),
}
, order_by => "project, attrname, system" , order_by => "project, attrname, system"
})]; })];
} }
sub all :Local { sub jobstatus :Local {
my ($self, $c, $page) = @_; my ($self, $c) = @_;
showJobStatus($c, $c->model('DB::Builds'));
}
sub showAllBuilds {
my ($c, $baseUri, $page, $builds) = @_;
$c->stash->{template} = 'all.tt'; $c->stash->{template} = 'all.tt';
$page = int($page) || 1; $page = int($page) || 1;
my $resultsPerPage = 50; my $resultsPerPage = 50;
my $nrBuilds = scalar($c->model('DB::Builds')->search({finished => 1})); my $nrBuilds = scalar($builds->search({finished => 1}));
$c->stash->{baseUri} = $baseUri;
$c->stash->{page} = $page; $c->stash->{page} = $page;
$c->stash->{resultsPerPage} = $resultsPerPage; $c->stash->{resultsPerPage} = $resultsPerPage;
$c->stash->{totalBuilds} = $nrBuilds; $c->stash->{totalBuilds} = $nrBuilds;
$c->stash->{builds} = [$c->model('DB::Builds')->search( $c->stash->{builds} = [$builds->search(
{finished => 1}, {order_by => "timestamp DESC", rows => $resultsPerPage, page => $page})]; {finished => 1}, {order_by => "timestamp DESC", rows => $resultsPerPage, page => $page})];
} }
sub all :Local {
my ($self, $c, $page) = @_;
showAllBuilds($c, $c->uri_for("/all"), $page, $c->model('DB::Builds'));
}
sub updateProject { sub updateProject {
my ($c, $project) = @_; my ($c, $project) = @_;
my $projectName = trim $c->request->params->{name}; my $projectName = trim $c->request->params->{name};
die "Invalid project name: $projectName" unless $projectName =~ /^[[:alpha:]]\w*$/; die "Invalid project name: $projectName" unless $projectName =~ /^[[:alpha:]]\w*$/;
@ -277,7 +293,7 @@ sub updateProject {
sub project :Local { sub project :Local {
my ($self, $c, $projectName, $subcommand) = @_; my ($self, $c, $projectName, $subcommand, $arg) = @_;
$c->stash->{template} = 'project.tt'; $c->stash->{template} = 'project.tt';
(my $project) = $c->model('DB::Projects')->search({ name => $projectName }); (my $project) = $c->model('DB::Projects')->search({ name => $projectName });
@ -285,9 +301,20 @@ sub project :Local {
my $isPosted = $c->request->method eq "POST"; my $isPosted = $c->request->method eq "POST";
$c->stash->{curProject} = $project;
$subcommand = "" unless defined $subcommand; $subcommand = "" unless defined $subcommand;
if ($subcommand ne "") { if ($subcommand eq "jobstatus") {
return showJobStatus($c, scalar $project->builds);
}
elsif ($subcommand eq "all") {
return showAllBuilds($c, $c->uri_for("/project", $projectName, "all"),
$arg, scalar $project->builds);
}
elsif ($subcommand ne "") {
return requireLogin($c) if !$c->user_exists; return requireLogin($c) if !$c->user_exists;
@ -317,8 +344,6 @@ sub project :Local {
} }
} }
$c->stash->{curProject} = $project;
getBuildStats($c, scalar $project->builds); getBuildStats($c, scalar $project->builds);
$c->stash->{jobNames} = $c->stash->{jobNames} =

View file

@ -1,20 +1,20 @@
[% WRAPPER layout.tt title="All Builds" %] [% WRAPPER layout.tt title="All Builds" %]
[% PROCESS common.tt %] [% PROCESS common.tt %]
<h1>All Builds</h1> <h1>All Builds[% IF curProject %] in Project <tt>[% curProject.name %]</tt>[% END %]</h1>
<p>Showing builds [% (page - 1) * resultsPerPage + 1 %] - [% (page - 1) * resultsPerPage + builds.size %] <p>Showing builds [% (page - 1) * resultsPerPage + 1 %] - [% (page - 1) * resultsPerPage + builds.size %]
out of [% totalBuilds %] in order of descending timestamp.</p> out of [% totalBuilds %] in order of descending timestamp.</p>
[% PROCESS renderBuildList %] [% PROCESS renderBuildList %]
[<a href="[% c.uri_for('/all' 1) %]">First</a>] [<a href="[% "$baseUri/1" %]">First</a>]
[% IF page > 1 %] [% IF page > 1 %]
[<a href="[% c.uri_for('/all' (page - 1)) %]">Prev</a>] [<a href="[% "$baseUri/"; (page - 1) %]">Prev</a>]
[% END %] [% END %]
[% IF page * resultsPerPage < totalBuilds %] [% IF page * resultsPerPage < totalBuilds %]
[<a href="[% c.uri_for('/all' (page + 1)) %]">Next</a>] [<a href="[% "$baseUri/"; (page + 1) %]">Next</a>]
[% END %] [% END %]
[<a href="[% c.uri_for('/all' (totalBuilds - 1) div resultsPerPage + 1) %]">Last</a>] [<a href="[% "$baseUri/"; (totalBuilds - 1) div resultsPerPage + 1 %]">Last</a>]
[% END %] [% END %]

View file

@ -1,7 +1,7 @@
[% WRAPPER layout.tt title="Job Status" %] [% WRAPPER layout.tt title="Job Status" %]
[% PROCESS common.tt %] [% PROCESS common.tt %]
<h1>Job Status</h1> <h1>Job Status[% IF curProject %] in Project <tt>[% curProject.name %]</tt>[% END %]</h1>
<p>Below are the latest builds for each job.</p> <p>Below are the latest builds for each job.</p>

View file

@ -98,7 +98,7 @@
[% IF curProject.name == project.name %] [% IF curProject.name == project.name %]
<ul class="subsubmenu"> <ul class="subsubmenu">
[% INCLUDE makeLink uri = c.uri_for('/project' project.name 'edit') title = "Edit" %] [% INCLUDE makeLink uri = c.uri_for('/project' project.name 'edit') title = "Edit" %]
[% INCLUDE makeLink uri = c.uri_for('/project' project.name 'status') title = "Status" %] [% INCLUDE makeLink uri = c.uri_for('/project' project.name 'jobstatus') title = "Job status" %]
[% INCLUDE makeLink uri = c.uri_for('/project' project.name 'all') title = "All builds" %] [% INCLUDE makeLink uri = c.uri_for('/project' project.name 'all') title = "All builds" %]
</ul> </ul>
[% END %] [% END %]