Add page showing latest build steps

This commit is contained in:
Eelco Dolstra 2015-07-10 15:08:34 +02:00
parent 0da08df4eb
commit b09f7e0989
8 changed files with 83 additions and 2 deletions

View file

@ -293,6 +293,30 @@ sub evals :Local Args(0) {
}
sub steps :Local Args(0) {
my ($self, $c) = @_;
$c->stash->{template} = 'steps.tt';
my $page = int($c->req->param('page') || "1") || 1;
my $resultsPerPage = 20;
$c->stash->{page} = $page;
$c->stash->{resultsPerPage} = $resultsPerPage;
$c->stash->{steps} = [ $c->model('DB::BuildSteps')->search(
{ starttime => { '!=', undef },
stoptime => { '!=', undef }
},
{ order_by => [ "stoptime desc" ],
rows => $resultsPerPage,
offset => ($page - 1) * $resultsPerPage
}) ];
$c->stash->{total} = approxTableSize($c, "IndexBuildStepsOnStopTime");
}
sub search :Local Args(0) {
my ($self, $c) = @_;
$c->stash->{template} = 'search.tt';
@ -340,9 +364,9 @@ sub search :Local Args(0) {
$c->stash->{buildsdrv} = [ $c->model('DB::Builds')->search(
{ "drvpath" => trim($query) },
{ order_by => ["id desc"] } ) ];
}
sub log :Local :Args(1) {
my ($self, $c, $path) = @_;

View file

@ -23,6 +23,7 @@ our @EXPORT = qw(
showStatus
getResponsibleAuthors
setCacheHeaders
approxTableSize
);
@ -296,4 +297,11 @@ sub setCacheHeaders {
}
sub approxTableSize {
my ($c, $name) = @_;
return $c->model('DB')->schema->storage->dbh->selectrow_hashref(
"select reltuples::int from pg_class where relname = lower(?)", { }, $name)->{"reltuples"};
}
1;

View file

@ -45,7 +45,7 @@
INCLUDE renderDuration duration = curTime - step.starttime;
END %]
</td>
<td>[% step.machine.split('@').1 || step.machine %]</td>
<td>[% INCLUDE renderMachineName machine=step.machine %]</td>
<td>
[% IF step.busy == 1 %]
<strong>Building</strong>

View file

@ -643,4 +643,9 @@ BLOCK createChart %]
[% END;
BLOCK renderMachineName;
machine ? stripSSHUser(machine).match('^([^\.]*)').0 : "localhost";
END;
%]

39
src/root/steps.tt Normal file
View file

@ -0,0 +1,39 @@
[% WRAPPER layout.tt title="Latest steps" %]
[% PROCESS common.tt %]
<p>Showing steps [% (page - 1) * resultsPerPage + 1 %] - [% (page - 1)
* resultsPerPage + steps.size %] of about [% total %] in
order of descending finish time.</p>
<table class="table table-striped table-condensed clickable-rows">
<thead>
<tr>
<th></th>
<th>What</th>
<th>Job</th>
<th>Build</th>
<th>Step</th>
<th>When</th>
<th>Duration</th>
<th>Machine</th>
</tr>
</thead>
<tbody>
[% FOREACH step IN steps %]
<tr>
<td>[% INCLUDE renderBuildStatusIcon buildstatus=step.status size=16 %]</td>
<td><tt>[% step.drvpath.match('-(.*).drv').0 %]</tt></td>
<td><tt>[% INCLUDE renderFullJobNameOfBuild build=step.build %]</tt></td>
<td><a href="[% c.uri_for('/build' step.build.id) %]">[% step.build.id %]</a></td>
<td><a class="row-link" href="[% c.uri_for('/build' step.build.id 'nixlog' step.stepnr 'tail-reload') %]">[% step.stepnr %]</a></td>
<td>[% INCLUDE renderRelativeDate timestamp=step.stoptime %]</td>
<td style="width: 10em">[% INCLUDE renderDuration duration = step.stoptime - step.starttime %] </td>
<td><tt>[% INCLUDE renderMachineName machine=step.machine %]</tt></td>
</tr>
[% END %]
</tbody>
</table>
[% INCLUDE renderPager %]
[% END %]

View file

@ -31,6 +31,9 @@
[% INCLUDE menuItem
uri = c.uri_for(c.controller('Root').action_for('all'))
title = "Latest builds" %]
[% INCLUDE menuItem
uri = c.uri_for(c.controller('Root').action_for('steps'))
title = "Latest steps" %]
[% END %]
[% IF project %]

View file

@ -595,6 +595,7 @@ create index IndexBuildProductsOnBuild on BuildProducts(build);
create index IndexBuildStepsOnBusy on BuildSteps(busy) where busy = 1;
create index IndexBuildStepsOnDrvPath on BuildSteps(drvpath);
create index IndexBuildStepsOnPropagatedFrom on BuildSteps(propagatedFrom) where propagatedFrom is not null;
create index IndexBuildStepsOnStopTime on BuildSteps(stopTime desc) where startTime is not null and stopTime is not null;
create index IndexBuildStepOutputsOnPath on BuildStepOutputs(path);
create index IndexBuildsOnFinished on Builds(finished) where finished = 0;
create index IndexBuildsOnFinishedBusy on Builds(finished, busy) where finished = 0;

1
src/sql/upgrade-37.sql Normal file
View file

@ -0,0 +1 @@
create index IndexBuildStepsOnStopTime on BuildSteps(stopTime desc) where startTime is not null and stopTime is not null;