about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Build.PL1
-rw-r--r--lib/jitterbug/Project.pm10
-rw-r--r--views/project/index.tt2
3 files changed, 10 insertions, 3 deletions
diff --git a/Build.PL b/Build.PL
index 10991a6..244c593 100644
--- a/Build.PL
+++ b/Build.PL
@@ -30,6 +30,7 @@ my $builder = Module::Build->new(
         'App::perlbrew'            => 0,
         'Dist::Zilla'              => 0,
         'Email::Stuff'             => 0,
+        'Time::Elapsed'            => 0,
         'DBIx::Class::DeploymentHandler' => 0,
     },
     add_to_cleanup      => [ 'jitterbug-' ],
diff --git a/lib/jitterbug/Project.pm b/lib/jitterbug/Project.pm
index 7616843..9d57354 100644
--- a/lib/jitterbug/Project.pm
+++ b/lib/jitterbug/Project.pm
@@ -5,6 +5,7 @@ use Dancer::Plugin::DBIC;
 use jitterbug::Plugin::Template;
 
 use Digest::MD5 qw/md5_hex/;
+use Time::Elapsed qw( elapsed );
 use DateTime;
 use XML::Feed;
 
@@ -76,8 +77,13 @@ sub _sorted_builds {
 
     my @builds;
     while ( my $c = $commits->next ) {
-        my $content = from_json($c->content);
-        $content->{id} = $c->sha256 if (!$content->{id});
+        my $content = from_json( $c->content );
+        $content->{id} = $c->sha256 if ( !$content->{id} );
+        if ( $content->{build}->{start_time} ) {
+            $content->{time_elapsed} =
+              elapsed( $content->{build}->{end_time} -
+                  $content->{build}->{start_time} );
+        }
         push @builds, $content;
     }
 
diff --git a/views/project/index.tt b/views/project/index.tt
index db123c0..f8d0ea2 100644
--- a/views/project/index.tt
+++ b/views/project/index.tt
@@ -40,7 +40,7 @@
               <: } :>
               <br />
               <: if $commit.build.start_time { :>
-                built in&nbsp;<: $commit.build.end_time - $commit.build.start_time :>&nbsp;seconds
+                built in&nbsp;<: $commit.time_elapsed :>
               <: } else { :>
                     running now
               <: } :>