File Coverage

blib/lib/App/bif/show/hub.pm
Criterion Covered Total %
statement 12 24 50.0
branch 0 6 0.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 17 35 48.5


line stmt bran cond sub pod time code
1             package App::bif::show::hub;
2 1     1   4810 use strict;
  1         2  
  1         25  
3 1     1   6 use warnings;
  1         2  
  1         35  
4 1     1   5 use Bif::Mo;
  1         2  
  1         12  
5              
6             our $VERSION = '0.1.5_7';
7             extends 'App::bif::show';
8              
9             sub run {
10 1     1 1 1 my $self = shift;
11 1         5 my $opts = $self->opts;
12 1         7 my $db = $self->db;
13 0 0         my $hub = $self->get_hub( $opts->{id} ? $opts->{id} : $opts->{name} );
14              
15 0           my @data;
16              
17             push(
18             @data,
19             $self->header(
20             ' ID', $hub->{id},
21 0 0         $opts->{full} ? $hub->{uuid} : substr( $hub->{uuid}, 1, 8 )
22             ),
23             );
24              
25 0           push( @data, $self->header( ' Location', $hub->{location}, ) );
26              
27             my $info = $db->xhashref(
28             select => [qw/n.ctime n.ctimetz n.mtime n.mtimetz/],
29             from => 'nodes n',
30             inner_join => 'changes c',
31             on => 'c.id = n.first_change_id',
32             where => { 'n.id' => $hub->{id} },
33 0           );
34              
35             # Remove 1 from the count to account for the hub itself being a
36             # project
37             my $pcount = $db->xval(
38             select => 'COUNT(ph.project_id) - 1',
39             from => 'project_hubs ph',
40             where => { 'ph.hub_id' => $hub->{id} },
41 0           );
42 0           push( @data, $self->header( ' Projects', $pcount ) );
43              
44 0           $self->start_pager;
45 0           print $self->render_table( 'l l', [ 'Hub', $hub->{name} ], \@data, 1 );
46 0           print "\n";
47              
48             $self->dispatch( 'App::bif::log::hub', opts => { id => $hub->{id} } )
49 0 0         if $opts->{log};
50              
51 0           return $self->ok( 'ShowHub', \@data );
52             }
53              
54             1;
55             __END__