From 45605291eff0216a8d0b4e1d22dde4a3d69cbb15 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Mon, 24 Jan 2011 20:53:24 +0100 Subject: load tasks and display them on the dashboard --- lib/jitterbug.pm | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'lib') 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; -- cgit 1.4.1 From cfdb6f235e3b32541a1743c47fbfe17c957116d2 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Mon, 24 Jan 2011 20:53:54 +0100 Subject: add pending status to the schema (TODO: need a script to migrate the schema) --- lib/jitterbug/Schema/Result/Task.pm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/jitterbug/Schema/Result/Task.pm b/lib/jitterbug/Schema/Result/Task.pm index e63e101..331deb4 100644 --- a/lib/jitterbug/Schema/Result/Task.pm +++ b/lib/jitterbug/Schema/Result/Task.pm @@ -12,6 +12,10 @@ __PACKAGE__->add_columns( data_type => 'int', is_foreign_key => 1, }, + running => { + data_type => 'bool', + default_value => 0, + }, ); __PACKAGE__->set_primary_key('taskid'); -- cgit 1.4.1 From 7b63d950c4dd122777fcd8a1aab9b01f3d46208f Mon Sep 17 00:00:00 2001 From: franck cuny Date: Mon, 24 Jan 2011 20:54:06 +0100 Subject: we want a find, not a search here --- lib/jitterbug/Task.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/jitterbug/Task.pm b/lib/jitterbug/Task.pm index f14a9c6..998e9e4 100644 --- a/lib/jitterbug/Task.pm +++ b/lib/jitterbug/Task.pm @@ -7,7 +7,7 @@ use jitterbug::Plugin::Template; get '/:task_id' => sub { my $task_id = params->{task_id}; - my $task = schema->resultset('Task')->search($task_id); + my $task = schema->resultset('Task')->find($task_id); if (!$task) { render_error("task doesn't exists", 404); -- cgit 1.4.1 From 672eac1ffb7aaf62c651ee63cf069c8826dfca41 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Mon, 24 Jan 2011 21:29:11 +0100 Subject: add version to our schema --- lib/jitterbug/Schema.pm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/jitterbug/Schema.pm b/lib/jitterbug/Schema.pm index 5014c12..5b42275 100644 --- a/lib/jitterbug/Schema.pm +++ b/lib/jitterbug/Schema.pm @@ -1,6 +1,8 @@ package jitterbug::Schema; use base qw/DBIx::Class::Schema/; +our $VERSION = '2'; + __PACKAGE__->load_namespaces(); 1; -- cgit 1.4.1 From 696b319385daa88837af21de1b3a2a3c3c3619ea Mon Sep 17 00:00:00 2001 From: franck cuny Date: Mon, 24 Jan 2011 21:46:43 +0100 Subject: display current build if any --- lib/jitterbug.pm | 3 ++- views/index.tt | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug.pm b/lib/jitterbug.pm index 2da9e09..1bf3aab 100644 --- a/lib/jitterbug.pm +++ b/lib/jitterbug.pm @@ -15,7 +15,8 @@ get '/' => sub { my $projects = _get_projects(); my ( $builds, $runnings ) = _get_builds(); - template 'index', { projects => $projects, builds => $builds }; + template 'index', + { projects => $projects, builds => $builds, runnings => $runnings }; }; sub _get_projects { diff --git a/views/index.tt b/views/index.tt index f82aa5e..d657f48 100644 --- a/views/index.tt +++ b/views/index.tt @@ -2,6 +2,15 @@

Dashboard

+
+ : if $runnings { + The following projects are building: + : for $runnings -> $running { + <: $running.project :> + : } + : } +
+
@@ -26,7 +35,7 @@
-

Builds pending

+

Builds pending (<: $builds.size :>)

    -- cgit 1.4.1 From 207eb36a76f53e35fbbbb9ef5f5ed7e1ddae8c59 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Sun, 13 Feb 2011 13:56:53 +0100 Subject: prepare to update schema again --- lib/jitterbug/Schema.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/jitterbug/Schema.pm b/lib/jitterbug/Schema.pm index 5b42275..f47d7e9 100644 --- a/lib/jitterbug/Schema.pm +++ b/lib/jitterbug/Schema.pm @@ -1,7 +1,7 @@ package jitterbug::Schema; use base qw/DBIx::Class::Schema/; -our $VERSION = '2'; +our $VERSION = '3'; __PACKAGE__->load_namespaces(); -- cgit 1.4.1 From afca829e55239b89a195c1035e8e5b40ca86e011 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Sun, 13 Feb 2011 13:57:13 +0100 Subject: column started_when: datetime when the build started --- lib/jitterbug/Schema/Result/Task.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/jitterbug/Schema/Result/Task.pm b/lib/jitterbug/Schema/Result/Task.pm index 331deb4..2eaed62 100644 --- a/lib/jitterbug/Schema/Result/Task.pm +++ b/lib/jitterbug/Schema/Result/Task.pm @@ -2,6 +2,7 @@ package jitterbug::Schema::Result::Task; use base qw/DBIx::Class::Core/; __PACKAGE__->table('task'); +__PACKAGE__->load_components(qw/InflateColumn::DateTime/); __PACKAGE__->add_columns( taskid => { data_type => 'int', @@ -13,8 +14,13 @@ __PACKAGE__->add_columns( is_foreign_key => 1, }, running => { - data_type => 'bool', - default_value => 0, + data_type => 'bool', + default_value => 0, + }, + started_when => { + data_type => 'datetime', + is_nullable => 1, + datetime_undef_if_invalid => 1 }, ); -- cgit 1.4.1