« blib/lib/App/Netdisco/Web/Plugin/Report/HalfDuplex.pm
↑ Summary
blib/lib/App/Netdisco/Web/Plugin/Report/IpInventory.pm »
| 1 | package App::Netdisco::Web::Plugin::Report::InventoryByModelByOS; | ||
| 2 | |||
| 3 | use Dancer ':syntax'; | ||
| 4 | use Dancer::Plugin::DBIC; | ||
| 5 | use Dancer::Plugin::Auth::Extensible; | ||
| 6 | |||
| 7 | use App::Netdisco::Web::Plugin; | ||
| 8 | |||
| 9 | register_report( | ||
| 10 | { category => 'Device', | ||
| 11 | tag => 'inventorybymodelbyos', | ||
| 12 | label => 'Inventory by Model by OS', | ||
| 13 | provides_csv => 0, | ||
| 14 | } | ||
| 15 | ); | ||
| 16 | |||
| 17 | get '/ajax/content/report/inventorybymodelbyos' => require_login sub { | ||
| 18 | my @results = schema(vars->{'tenant'})->resultset('Device')->search(undef, { | ||
| 19 | columns => [qw/vendor model os os_ver/], | ||
| 20 | select => [ { count => 'os_ver' } ], | ||
| 21 | as => [qw/ os_ver_count /], | ||
| 22 | group_by => [qw/ vendor model os os_ver /], | ||
| 23 | order_by => ['vendor', 'model', { -desc => 'count' }, 'os_ver'], | ||
| 24 | })->hri->all; | ||
| 25 | |||
| 26 | template 'ajax/report/inventorybymodelbyos.tt', { results => \@results, }, | ||
| 27 | { layout => undef }; | ||
| 28 | }; | ||
| 29 | |||
| 30 | 1; |