From f9572e4d1ef63ead5813a452d3a55f4063240f4c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 7 Apr 2009 15:49:02 +0000 Subject: [PATCH] * Provide some redirects to the latest successful build for a job (or project, or jobset, or globally, but that's not all that useful). This is useful if you want to link to the latest build. --- src/lib/Hydra/Base/Controller/ListBuilds.pm | 30 +++++++++++++++++++++ src/lib/Hydra/Controller/Job.pm | 2 ++ src/root/job.tt | 13 +++++++++ 3 files changed, 45 insertions(+) diff --git a/src/lib/Hydra/Base/Controller/ListBuilds.pm b/src/lib/Hydra/Base/Controller/ListBuilds.pm index b187e97c..2b1352e1 100644 --- a/src/lib/Hydra/Base/Controller/ListBuilds.pm +++ b/src/lib/Hydra/Base/Controller/ListBuilds.pm @@ -59,4 +59,34 @@ sub nix : Chained('get_builds') PathPart('channel') CaptureArgs(1) { } +# Redirect to the latest successful build. +sub latest : Chained('get_builds') PathPart('latest') { + my ($self, $c) = @_; + + my ($latest) = joinWithResultInfo($c, $c->stash->{allBuilds}) + ->search({finished => 1, buildstatus => 0}, {order_by => ["timestamp DESC"]}); + + notFound "There is no successful build to redirect to." unless defined $latest; + + $c->res->redirect($c->uri_for($c->controller('Build')->action_for("view_build"), [$latest->id])); + +} + + +# Redirect to the latest successful build for a specific platform. +sub latest_for : Chained('get_builds') PathPart('latest-for') { + my ($self, $c, $system) = @_; + + notFound($c, "You need to specify a platform type in the URL.") unless defined $system; + + my ($latest) = joinWithResultInfo($c, $c->stash->{allBuilds}) + ->search({finished => 1, buildstatus => 0, system => $system}, {order_by => ["timestamp DESC"]}); + + notFound($c, "There is no successful build for platform `$system' to redirect to.") unless defined $latest; + + $c->res->redirect($c->uri_for($c->controller('Build')->action_for("view_build"), [$latest->id])); + +} + + 1; diff --git a/src/lib/Hydra/Controller/Job.pm b/src/lib/Hydra/Controller/Job.pm index 8b46de2f..20ca09f4 100644 --- a/src/lib/Hydra/Controller/Job.pm +++ b/src/lib/Hydra/Controller/Job.pm @@ -23,6 +23,8 @@ sub overview : Chained('job') PathPart('') Args(0) { $c->stash->{template} = 'job.tt'; getBuildStats($c, scalar $c->stash->{job}->builds); + + $c->stash->{systems} = [$c->stash->{job}->builds->search({}, {select => ["system"], distinct => 1})]; } diff --git a/src/root/job.tt b/src/root/job.tt index 89c44ddf..2a34d147 100644 --- a/src/root/job.tt +++ b/src/root/job.tt @@ -23,6 +23,19 @@ +

Latest builds

+ + + +

Statistics

[% INCLUDE showBuildStats %]