blib/lib/App/Netdisco/Web/Plugin/AdminTask/DuplicateDevices.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 35 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package App::Netdisco::Web::Plugin::AdminTask::DuplicateDevices;
2  
3 use Dancer ':syntax';
4 use Dancer::Plugin::Ajax;
5 use Dancer::Plugin::DBIC;
6 use Dancer::Plugin::Auth::Extensible;
7  
8 use App::Netdisco::Web::Plugin;
9  
10 register_admin_task({
11 tag => 'duplicatedevices',
12 label => 'Duplicate Devices',
13 });
14  
15 ajax '/ajax/content/admin/duplicatedevices' => require_role admin => sub {
16 my @set = schema(vars->{'tenant'})->resultset('Device')->search({
17 serial => { '-in' => schema(vars->{'tenant'})->resultset('Device')->search({
18 '-and' => [serial => { '!=', undef }, serial => { '!=', '' }],
19 }, {
20 group_by => ['serial'],
21 having => \'count(*) > 1',
22 columns => 'serial',
23 })->as_query
24 },
25 }, { columns => [qw/ip dns contact location name model os_ver serial/] })
26 ->with_times->hri->all;
27  
28 content_type('text/html');
29 template 'ajax/admintask/duplicatedevices.tt', {
30 results => \@set
31 }, { layout => undef };
32 };
33  
34 true;