From 1fdc258de0d7f97af428de34e8be019fca3db251 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sat, 25 Apr 2015 03:53:57 +0200 Subject: [PATCH] ListBuilds: Simplify nix channel dispatcher. We only allow channel/latest anyway, so it really doesn't make sense to explicitly specify this in the PathPart and provide other dispatcher once we have more than just "latest", which greatly simplifies the dispatch tree. Signed-off-by: aszlig --- src/lib/Hydra/Base/Controller/ListBuilds.pm | 25 ++++++++------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/lib/Hydra/Base/Controller/ListBuilds.pm b/src/lib/Hydra/Base/Controller/ListBuilds.pm index b971d5e8..2568b117 100644 --- a/src/lib/Hydra/Base/Controller/ListBuilds.pm +++ b/src/lib/Hydra/Base/Controller/ListBuilds.pm @@ -32,23 +32,16 @@ sub all : Chained('get_builds') PathPart { } -sub nix : Chained('get_builds') PathPart('channel') CaptureArgs(1) { +sub nix : Chained('get_builds') PathPart('channel/latest') CaptureArgs(1) { my ($self, $c, $channelName) = @_; - eval { - if ($channelName eq "latest") { - $c->stash->{channelName} = $c->stash->{channelBaseName} . "-latest"; - $c->stash->{channelBuilds} = $c->stash->{latestSucceeded} - ->search_literal("exists (select 1 from buildproducts where build = me.id and type = 'nix-build')") - ->search({}, { columns => [@buildListColumns, 'drvpath', 'description', 'homepage'] - , join => ["buildoutputs"] - , order_by => ["me.id", "buildoutputs.name"] - , '+select' => ['buildoutputs.path', 'buildoutputs.name'], '+as' => ['outpath', 'outname'] }); - } - else { - notFound($c, "Unknown channel `$channelName'."); - } - }; - error($c, $@) if $@; + + $c->stash->{channelName} = $c->stash->{channelBaseName} . "-latest"; + $c->stash->{channelBuilds} = $c->stash->{latestSucceeded} + ->search_literal("exists (select 1 from buildproducts where build = me.id and type = 'nix-build')") + ->search({}, { columns => [@buildListColumns, 'drvpath', 'description', 'homepage'] + , join => ["buildoutputs"] + , order_by => ["me.id", "buildoutputs.name"] + , '+select' => ['buildoutputs.path', 'buildoutputs.name'], '+as' => ['outpath', 'outname'] }); }