diff --git a/Changes b/Changes index f694de56..ec4b5c38 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +2.039014 - + + [BUG FIXES] + + * #372 fix inventory doesn't work with only one device + 2.039013 - 2018-03-02 [ENHANCEMENTS] diff --git a/lib/App/Netdisco/DB/ResultSet/Device.pm b/lib/App/Netdisco/DB/ResultSet/Device.pm index 2e8820f0..0dc4e9d2 100644 --- a/lib/App/Netdisco/DB/ResultSet/Device.pm +++ b/lib/App/Netdisco/DB/ResultSet/Device.pm @@ -475,7 +475,7 @@ sub has_layer { =back -=head2 get_models +=head2 get_platforms Returns a sorted list of Device models with the following columns only: @@ -494,15 +494,15 @@ Netdisco database. =cut -sub get_models { +sub get_platforms { my $rs = shift; return $rs->search({}, { - select => [ 'vendor', 'model', { count => 'ip' } ], - as => [qw/vendor model count/], + 'columns' => [ 'vendor', 'model' ], + '+select' => [{ count => 'ip' }], + '+as' => ['count'], group_by => [qw/vendor model/], order_by => [{-asc => 'vendor'}, {-asc => 'model'}], - }) - + }); } =head2 get_releases @@ -527,8 +527,9 @@ Netdisco database. sub get_releases { my $rs = shift; return $rs->search({}, { - select => [ 'os', 'os_ver', { count => 'ip' } ], - as => [qw/os os_ver count/], + columns => ['os', 'os_ver'], + '+select' => [ { count => 'ip' } ], + '+as' => [qw/count/], group_by => [qw/os os_ver/], order_by => [{-asc => 'os'}, {-asc => 'os_ver'}], }) diff --git a/lib/App/Netdisco/Web/Plugin/Inventory.pm b/lib/App/Netdisco/Web/Plugin/Inventory.pm index 4dc93679..c6fcb311 100644 --- a/lib/App/Netdisco/Web/Plugin/Inventory.pm +++ b/lib/App/Netdisco/Web/Plugin/Inventory.pm @@ -13,14 +13,13 @@ register_navbar_item({ }); get '/inventory' => require_login sub { - my $models = schema('netdisco')->resultset('Device')->get_models(); + my $platforms = schema('netdisco')->resultset('Device')->get_platforms(); my $releases = schema('netdisco')->resultset('Device')->get_releases(); var(nav => 'inventory'); - template 'inventory', { - models => $models, - releases => $releases, + platforms => [$platforms->hri->all], + releases => [$releases->hri->all], }; }; diff --git a/share/views/inventory.tt b/share/views/inventory.tt index ce379b94..8109b40b 100644 --- a/share/views/inventory.tt +++ b/share/views/inventory.tt @@ -1,5 +1,5 @@