diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 822b7ad8..f921ff9e 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -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) = @_; diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index 35e15927..d31b3f53 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -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; diff --git a/src/root/build.tt b/src/root/build.tt index 160fca7e..9ecd5cd6 100644 --- a/src/root/build.tt +++ b/src/root/build.tt @@ -45,7 +45,7 @@ INCLUDE renderDuration duration = curTime - step.starttime; END %] - [% step.machine.split('@').1 || step.machine %] + [% INCLUDE renderMachineName machine=step.machine %] [% IF step.busy == 1 %] Building diff --git a/src/root/common.tt b/src/root/common.tt index 61f08b4c..ef3d793a 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -643,4 +643,9 @@ BLOCK createChart %] [% END; +BLOCK renderMachineName; +machine ? stripSSHUser(machine).match('^([^\.]*)').0 : "localhost"; +END; + + %] diff --git a/src/root/steps.tt b/src/root/steps.tt new file mode 100644 index 00000000..26260ce7 --- /dev/null +++ b/src/root/steps.tt @@ -0,0 +1,39 @@ +[% WRAPPER layout.tt title="Latest steps" %] +[% PROCESS common.tt %] + +

Showing steps [% (page - 1) * resultsPerPage + 1 %] - [% (page - 1) +* resultsPerPage + steps.size %] of about [% total %] in +order of descending finish time.

+ + + + + + + + + + + + + + + + [% FOREACH step IN steps %] + + + + + + + + + + + [% END %] + +
WhatJobBuildStepWhenDurationMachine
[% INCLUDE renderBuildStatusIcon buildstatus=step.status size=16 %][% step.drvpath.match('-(.*).drv').0 %][% INCLUDE renderFullJobNameOfBuild build=step.build %][% step.build.id %][% step.stepnr %][% INCLUDE renderRelativeDate timestamp=step.stoptime %][% INCLUDE renderDuration duration = step.stoptime - step.starttime %] [% INCLUDE renderMachineName machine=step.machine %]
+ +[% INCLUDE renderPager %] + +[% END %] diff --git a/src/root/topbar.tt b/src/root/topbar.tt index c1ec295e..81972517 100644 --- a/src/root/topbar.tt +++ b/src/root/topbar.tt @@ -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 %] diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 8752bacc..3d22d942 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -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; diff --git a/src/sql/upgrade-37.sql b/src/sql/upgrade-37.sql new file mode 100644 index 00000000..c04b119b --- /dev/null +++ b/src/sql/upgrade-37.sql @@ -0,0 +1 @@ +create index IndexBuildStepsOnStopTime on BuildSteps(stopTime desc) where startTime is not null and stopTime is not null;