summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2011-05-09 10:45:05 +0200
committerfranck cuny <franck@lumberjaph.net>2011-05-09 16:42:15 +0200
commitf712cc7006c170c25f414a67a90bcb7df6d298cb (patch)
treef39846dcf4e4e76b35bfb8237d1e7a69a44b646b /lib
parentadd a new route to the API to delete a task (diff)
downloadjitterbug-f712cc7006c170c25f414a67a90bcb7df6d298cb.tar.gz
add a new route to the API to list all tasks
Signed-off-by: franck cuny <franck@lumberjaph.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/jitterbug/WebService.pm23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/jitterbug/WebService.pm b/lib/jitterbug/WebService.pm
index d0cf92f..53d84bd 100644
--- a/lib/jitterbug/WebService.pm
+++ b/lib/jitterbug/WebService.pm
@@ -51,4 +51,27 @@ del '/task/:id' => sub {
{status => "task $id deleted"};
};
+get '/tasks' => sub {
+ my $tasks = schema->resultset('Task')->search();
+
+ my $content;
+
+ # I think we should never use internal ID when there is a sha256 available
+ while ( my $task = $tasks->next ) {
+ push @$content,
+ {
+ id => $task->sha256,
+ running => $task->running,
+ started_when => $task->started_when,
+ project => {
+ id => $task->projectid,
+ name => $task->project->name,
+ },
+ commit => from_json($task->commit->content),
+ };
+ }
+
+ {tasks => $content};
+};
+
1;