blib/lib/App/Netdisco/DB/Result/Virtual/DeviceLastJobs.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::DeviceLastJobs;
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 # The most recent finished job per device and action, whatever its status:
11 # a failing macsuck is the case worth seeing, so this is not limited to done
12 # jobs as SlowDevices is.
13 __PACKAGE__->table('device_last_jobs');
14 __PACKAGE__->result_source_instance->is_virtual(1);
15 __PACKAGE__->result_source_instance->view_definition(<<ENDSQL
16 SELECT DISTINCT ON (device, action)
17 device, action, status,
18 floor(extract(epoch FROM started)) AS started_epoch,
19 extract(epoch FROM (finished - started)) AS duration
20 FROM admin
21 WHERE device IS NOT NULL
22 AND started IS NOT NULL
23 AND finished IS NOT NULL
24 ORDER BY device, action, started DESC
25 ENDSQL
26 );
27  
28 __PACKAGE__->add_columns(
29 "device",
30 { data_type => "inet", is_nullable => 1 },
31 "action",
32 { data_type => "text", is_nullable => 1 },
33 "status",
34 { data_type => "text", is_nullable => 1 },
35 "started_epoch",
36 { data_type => "bigint", is_nullable => 1 },
37 "duration",
38 { data_type => "numeric", is_nullable => 1 },
39 );
40  
41 1;