1package App::Netdisco::DB::Result::Virtual::PollerPerformance;
2
3use strict;
4use warnings;
5
6use base 'DBIx::Class::Core';
7
8__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
9
10__PACKAGE__->table('poller_performance');
11__PACKAGE__->result_source_instance->is_virtual(1);
12__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
13  SELECT action,
14         entered,
15         to_char( entered, 'YYYY-MM-DD HH24:MI:SS' ) AS entered_stamp,
16         COUNT( device ) AS number,
17         MIN( started ) AS start,
18         MAX( finished ) AS end,
19         justify_interval(
20           extract ( epoch FROM( max( finished ) - min( started ) ) )
21             * interval '1 second'
22         ) AS elapsed
23    FROM admin
24    WHERE action IN ( 'discover', 'macsuck', 'arpnip', 'nbtstat' )
25    GROUP BY action, entered
26    HAVING count( device ) > 1
27      AND SUM( CASE WHEN status LIKE 'queued%' THEN 1 ELSE 0 END ) = 0
28    ORDER BY entered DESC, elapsed DESC
29    LIMIT 30
30ENDSQL
31);
32
33__PACKAGE__->add_columns(
34  "action",
35  { data_type => "text", is_nullable => 1 },
36  "entered",
37  { data_type => "timestamp", is_nullable => 1 },
38  "entered_stamp",
39  { data_type => "text", is_nullable => 1 },
40  "number",
41  { data_type => "integer", is_nullable => 1 },
42  "start",
43  { data_type => "timestamp", is_nullable => 1 },
44  "end",
45  { data_type => "timestamp", is_nullable => 1 },
46  "elapsed",
47  { data_type => "interval", is_nullable => 1 },
48);
49
501;
51