about summary refs log tree commit diff
path: root/lib/jitterbug.pm
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2011-02-13 16:20:59 +0100
committerfranck cuny <franck@lumberjaph.net>2011-02-13 16:20:59 +0100
commite81938b20ae19d472a6f835f8af01a428b8724de (patch)
treed6cea5e811f60fcd8f3c94ee1d9b4cf247404531 /lib/jitterbug.pm
parentMake jitterbug::Test use the current perl interp (diff)
parentMerge branch 'feature/stack_builds' into devel (diff)
downloadjitterbug-e81938b20ae19d472a6f835f8af01a428b8724de.tar.gz
Merge branch 'devel'
* devel:
  add more tests
  inside the hook, we check if we can add more than one task for this project
  add configuration option to skip some branches; add tests for the Hook
  that's why we want datetime
  use DateTime
  update templates to show informations about running tasks
  column started_when: datetime when the build started
  prepare to update schema again
  display current build if any
  add sql schema for various version
  don't ignore .sql files
  script to migrate/upgrade dbix schema
  add version to our schema
  update templates and css
  we want a find, not a search here
  add pending status to the schema (TODO: need a script to migrate the schema)
  load tasks and display them on the dashboard
Diffstat (limited to 'lib/jitterbug.pm')
-rw-r--r--lib/jitterbug.pm32
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/jitterbug.pm b/lib/jitterbug.pm
index c876cb6..1bf3aab 100644
--- a/lib/jitterbug.pm
+++ b/lib/jitterbug.pm
@@ -9,9 +9,17 @@ 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, runnings => $runnings };
+};
+
+sub _get_projects {
 
     my @projects = ();
 
@@ -41,7 +49,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;