about summary refs log tree commit diff
path: root/lib/jitterbug/Task.pm
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2011-05-09 11:14:03 +0200
committerfranck cuny <franck@lumberjaph.net>2011-05-09 16:43:04 +0200
commit60cf9a7981d9bc4e8a5d8e4126b26546451ae60b (patch)
tree2a42c5bc1022dd881a7610f43a2de9a70cf67559 /lib/jitterbug/Task.pm
parentadd a new route to the API to list all tasks (diff)
downloadjitterbug-60cf9a7981d9bc4e8a5d8e4126b26546451ae60b.tar.gz
don't show started_when when a task is not started (closes GH #58)
Signed-off-by: franck cuny <franck@lumberjaph.net>
Diffstat (limited to 'lib/jitterbug/Task.pm')
-rw-r--r--lib/jitterbug/Task.pm20
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/jitterbug/Task.pm b/lib/jitterbug/Task.pm
index b435de3..6b49b47 100644
--- a/lib/jitterbug/Task.pm
+++ b/lib/jitterbug/Task.pm
@@ -4,23 +4,21 @@ use Dancer ':syntax';
 use Dancer::Plugin::DBIC;
 use jitterbug::Plugin::Template;
 
-get '/:task_id' => sub {
-    my $task_id = params->{task_id};
+get '/:id' => sub {
+    my $task = schema->resultset('Task')->find( params->{id} );
 
-    my $task = schema->resultset('Task')->find($task_id);
-    my $commit =
-      schema->resultset('Commit')->find( { sha256 => $task->sha256 } );
 
-    if (!$task) {
+    if ( !$task ) {
         send_error("task does not exist!", 404);
     }
 
-    if (!$commit){
-        render_error("commit doesn't exists", 404);
-    }
+    my $commit = from_json( $task->commit->content );
 
-    my $content = from_json($commit->content);
-    template 'task/index', {task => $task, commit => $content };
+    template 'task/index',
+      {
+        task   => { id => $task->id, started_when => $task->started_when },
+        commit => $commit
+      };
 };
 
 1;