Sponsoring The Perl Toolchain Summit 2025: Help make this important event another success Learn more

use Dancer ':syntax';
register_admin_task({
tag => 'duplicatedevices',
label => 'Duplicate Devices',
});
ajax '/ajax/content/admin/duplicatedevices' => require_role admin => sub {
my @set = schema('netdisco')->resultset('Device')->search({
serial => { '-in' => schema('netdisco')->resultset('Device')->search({
'-and' => [serial => { '!=', undef }, serial => { '!=', '' }],
}, {
group_by => ['serial'],
having => \'count(*) > 1',
columns => 'serial',
})->as_query
},
}, { columns => [qw/ip dns contact location name model os_ver serial/] })
->with_times->hri->all;
content_type('text/html');
template 'ajax/admintask/duplicatedevices.tt', {
results => \@set
}, { layout => undef };
};
true;