about summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2011-01-24 20:53:24 +0100
committerfranck cuny <franck@lumberjaph.net>2011-01-24 20:53:24 +0100
commit45605291eff0216a8d0b4e1d22dde4a3d69cbb15 (patch)
treea4b33bafcff37f49b5676cfed7aef5259387e931
parentupdate capsule (diff)
downloadjitterbug-45605291eff0216a8d0b4e1d22dde4a3d69cbb15.tar.gz
load tasks and display them on the dashboard
-rw-r--r--lib/jitterbug.pm31
1 files changed, 28 insertions, 3 deletions
diff --git a/lib/jitterbug.pm b/lib/jitterbug.pm
index c876cb6..2da9e09 100644
--- a/lib/jitterbug.pm
+++ b/lib/jitterbug.pm
@@ -9,9 +9,16 @@ our $VERSION = '0.1';
 load_app 'jitterbug::Hook',       prefix => '/hook';
 load_app 'jitterbug::Project',    prefix => '/project';
 load_app 'jitterbug::WebService', prefix => '/api';
-#load_app 'jitterbug::Task',       prefix => '/task';
+load_app 'jitterbug::Task',       prefix => '/task';
 
 get '/' => sub {
+    my $projects = _get_projects();
+    my ( $builds, $runnings ) = _get_builds();
+
+    template 'index', { projects => $projects, builds => $builds };
+};
+
+sub _get_projects {
 
     my @projects = ();
 
@@ -41,7 +48,25 @@ get '/' => sub {
       sort { $b->{last_build}->{timestamp} cmp $a->{last_build}->{timestamp} }
       @projects;
 
-    template 'index', {projects => \@projects};
-};
+    return \@projects;
+}
+
+sub _get_builds {
+
+    my @builds   = ();
+    my @runnings = ();
+
+    my $builds = schema->resultset('Task')->search();
+    while ( my $build = $builds->next ) {
+        my $build_desc = {
+            project => $build->project->name,
+            id      => $build->id,
+            running => $build->running,
+        };
+        $build->running ? push @runnings, $build_desc : push @builds,
+          $build_desc;
+    }
+    return ( \@builds, \@runnings );
+}
 
 true;