blib/lib/App/Netdisco/DB/Result/Virtual/SlowDevices.pm untested

filter: Statementstmt 0.0% 0 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 17 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::DB::Result::Virtual::SlowDevices;
2  
3 use strict;
4 use warnings;
5  
6 use base 'DBIx::Class::Core';
7  
8 __PACKAGE__->table_class('DBIx::Class::ResultSource::View');
9  
10 __PACKAGE__->table('slow_devices');
11 __PACKAGE__->result_source_instance->is_virtual(1);
12 __PACKAGE__->result_source_instance->view_definition(<<ENDSQL
13 SELECT a.action, a.device, a.started, a.finished,
14 justify_interval(extract(epoch FROM (a.finished - a.started)) * interval '1 second') AS elapsed
15 FROM admin a
16 INNER JOIN (
17 SELECT device, action, max(started) AS started
18 FROM admin
19 WHERE status = 'done'
20 AND action IN ('discover','macsuck','arpnip')
21 GROUP BY action, device
22 ) b
23 ON a.device = b.device AND a.started = b.started
24 ORDER BY elapsed desc, action, device
25 LIMIT 20
26 ENDSQL
27 );
28  
29 __PACKAGE__->add_columns(
30 "action",
31 { data_type => "text", is_nullable => 1 },
32 "device",
33 { data_type => "inet", is_nullable => 1 },
34 "started",
35 { data_type => "timestamp", is_nullable => 1 },
36 "finished",
37 { data_type => "timestamp", is_nullable => 1 },
38 "elapsed",
39 { data_type => "interval", is_nullable => 1 },
40 );
41  
42 1;