« blib/lib/App/Netdisco/DB/Result/Virtual/DuplexMismatch.pm
↑ Summary
blib/lib/App/Netdisco/DB/Result/Virtual/GenericReport.pm »
| 1 | use utf8; | ||
| 2 | package App::Netdisco::DB::Result::Virtual::FilteredSNMPObject; | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | use base 'DBIx::Class::Core'; | ||
| 8 | |||
| 9 | __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); | ||
| 10 | |||
| 11 | __PACKAGE__->table("filtered_snmp_object"); | ||
| 12 | __PACKAGE__->result_source_instance->is_virtual(1); | ||
| 13 | __PACKAGE__->result_source_instance->view_definition(<<ENDSQL | ||
| 14 | |||
| 15 | SELECT so.oid, so.oid_parts, so.mib, so.leaf, so.type, so.access, so.index, so.status, so.enum, so.descr, so.num_children, | ||
| 16 | count(db.oid) AS browser | ||
| 17 | FROM snmp_object so | ||
| 18 | |||
| 19 | LEFT JOIN device_browser db ON | ||
| 20 | (db.ip = ? AND | ||
| 21 | ((so.oid = db.oid) | ||
| 22 | OR (array_length(db.oid_parts,1) > ? | ||
| 23 | AND db.oid LIKE so.oid || '.%'))) | ||
| 24 | |||
| 25 | WHERE array_length(so.oid_parts,1) = ? | ||
| 26 | AND so.oid LIKE ?::text || '.%' | ||
| 27 | |||
| 28 | GROUP BY so.oid, so.oid_parts, so.mib, so.leaf, so.type, so.access, so.index, so.status, so.enum, so.descr, so.num_children | ||
| 29 | |||
| 30 | ENDSQL | ||
| 31 | ); | ||
| 32 | |||
| 33 | __PACKAGE__->add_columns( | ||
| 34 | 'oid' => { data_type => 'text' }, | ||
| 35 | 'oid_parts' => { data_type => 'integer[]' }, | ||
| 36 | 'mib' => { data_type => 'text' }, | ||
| 37 | 'leaf' => { data_type => 'text' }, | ||
| 38 | 'type' => { data_type => 'text' }, | ||
| 39 | 'access' => { data_type => 'text' }, | ||
| 40 | 'index' => { data_type => 'text[]' }, | ||
| 41 | 'status' => { data_type => 'text' }, | ||
| 42 | 'enum' => { data_type => 'text[]' }, | ||
| 43 | 'descr' => { data_type => 'text' }, | ||
| 44 | 'num_children' => { data_type => 'integer' }, | ||
| 45 | 'browser' => { data_type => 'integer' }, | ||
| 46 | ); | ||
| 47 | |||
| 48 | 1; |