From 0bd7abf10b7731c9b4655c74d9a609a46fa5e355 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 4 Mar 2009 17:24:08 +0000 Subject: [PATCH] * Controller for jobs which inherits all actions in ListBuilds. So for instance we get channels specific for each job. --- .../lib/Hydra/Base/Controller/ListBuilds.pm | 1 + src/Hydra/lib/Hydra/Controller/Job.pm | 35 +++++++++++++++++++ src/Hydra/lib/Hydra/Controller/Root.pm | 15 -------- src/Hydra/root/all.tt | 4 ++- src/Hydra/root/build.tt | 2 +- src/Hydra/root/common.tt | 2 +- src/Hydra/root/job.tt | 8 ----- 7 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 src/Hydra/lib/Hydra/Controller/Job.pm delete mode 100644 src/Hydra/root/job.tt diff --git a/src/Hydra/lib/Hydra/Base/Controller/ListBuilds.pm b/src/Hydra/lib/Hydra/Base/Controller/ListBuilds.pm index 95d91b26..b66fddf9 100644 --- a/src/Hydra/lib/Hydra/Base/Controller/ListBuilds.pm +++ b/src/Hydra/lib/Hydra/Base/Controller/ListBuilds.pm @@ -9,6 +9,7 @@ use Hydra::Helper::CatalystUtils; sub jobstatus : Chained('get_builds') PathPart Args(0) { my ($self, $c) = @_; + $c->stash->{template} = 'jobstatus.tt'; $c->stash->{latestBuilds} = getLatestBuilds($c, $c->stash->{allBuilds}, {}); } diff --git a/src/Hydra/lib/Hydra/Controller/Job.pm b/src/Hydra/lib/Hydra/Controller/Job.pm new file mode 100644 index 00000000..15f21b3c --- /dev/null +++ b/src/Hydra/lib/Hydra/Controller/Job.pm @@ -0,0 +1,35 @@ +package Hydra::Controller::Job; + +use strict; +use warnings; +use base 'Hydra::Base::Controller::ListBuilds'; +use Hydra::Helper::Nix; +use Hydra::Helper::CatalystUtils; + + +sub job : Chained('/project/project') PathPart('job') CaptureArgs(1) { + my ($self, $c, $jobName) = @_; + + $c->stash->{jobName} = $jobName; + + # !!! nothing to do here yet, since we don't have a jobs table. +} + + +sub index : Chained('job') PathPart('') Args(0) { + my ($self, $c) = @_; + $c->go($self->action_for("all")); +} + + +# Hydra::Base::Controller::ListBuilds needs this. +sub get_builds : Chained('job') PathPart('') CaptureArgs(0) { + my ($self, $c) = @_; + $c->stash->{allBuilds} = + $c->stash->{curProject}->builds->search({attrName => $c->stash->{jobName}}); + $c->stash->{channelBaseName} = + $c->stash->{curProject}->name . "-" . $c->stash->{jobName}; +} + + +1; diff --git a/src/Hydra/lib/Hydra/Controller/Root.pm b/src/Hydra/lib/Hydra/Controller/Root.pm index 6ffd29cd..fd8dfd36 100644 --- a/src/Hydra/lib/Hydra/Controller/Root.pm +++ b/src/Hydra/lib/Hydra/Controller/Root.pm @@ -219,21 +219,6 @@ sub release :Local { } -sub job :Local { - my ($self, $c, $projectName, $jobName) = @_; - $c->stash->{template} = 'job.tt'; - - my $project = $c->model('DB::Projects')->find($projectName); - notFound($c, "Project $projectName doesn't exist.") if !defined $project; - $c->stash->{curProject} = $project; - - $c->stash->{jobName} = $jobName; - $c->stash->{builds} = [$c->model('DB::Builds')->search( - {finished => 1, project => $projectName, attrName => $jobName}, - {order_by => "timestamp DESC"})]; -} - - # Hydra::Base::Controller::ListBuilds needs this. sub get_builds : Chained('/') PathPart('') CaptureArgs(0) { my ($self, $c) = @_; diff --git a/src/Hydra/root/all.tt b/src/Hydra/root/all.tt index 1d90dbe4..62218696 100644 --- a/src/Hydra/root/all.tt +++ b/src/Hydra/root/all.tt @@ -1,7 +1,9 @@ [% WRAPPER layout.tt title="All Builds" %] [% PROCESS common.tt %] -

All Builds[% IF curProject %] in Project [% curProject.name %][% END %]

+

All Builds + [% IF jobName %]for Job [% curProject.name %]:[% jobName %][% ELSE %] + [% IF curProject %] for Project [% curProject.name %][% END %][% END %]

Showing builds [% (page - 1) * resultsPerPage + 1 %] - [% (page - 1) * resultsPerPage + builds.size %] out of [% totalBuilds %] in order of descending timestamp.

diff --git a/src/Hydra/root/build.tt b/src/Hydra/root/build.tt index 28209841..ddc4578b 100644 --- a/src/Hydra/root/build.tt +++ b/src/Hydra/root/build.tt @@ -66,7 +66,7 @@ Job name: - [% build.attrname %] + [% build.attrname %] Nix name: diff --git a/src/Hydra/root/common.tt b/src/Hydra/root/common.tt index 0d325194..76bb0206 100644 --- a/src/Hydra/root/common.tt +++ b/src/Hydra/root/common.tt @@ -61,7 +61,7 @@ [% build.schedulingInfo.priority %] [% END %] [% build.get_column("project") %] - [% build.attrname %] + [% build.attrname %] [% build.resultInfo.releasename ? build.resultInfo.releasename : build.nixname %] [% build.system %] [% date.format(build.timestamp, '%Y-%m-%d %H:%M:%S') %] diff --git a/src/Hydra/root/job.tt b/src/Hydra/root/job.tt deleted file mode 100644 index b584c847..00000000 --- a/src/Hydra/root/job.tt +++ /dev/null @@ -1,8 +0,0 @@ -[% WRAPPER layout.tt title="Job ‘$curProject.name:$jobName’" %] -[% PROCESS common.tt %] - -

All builds for job [% curProject.name %]:[% jobName %]

- -[% PROCESS renderBuildList builds=builds %] - -[% END %]