34 lines
		
	
	
		
			774 B
		
	
	
	
		
			Perl
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			774 B
		
	
	
	
		
			Perl
		
	
	
	
	
	
| package App::Netdisco::DB::Result::Virtual::DevicePortSpeed;
 | |
| 
 | |
| use strict;
 | |
| use warnings;
 | |
| 
 | |
| use base 'DBIx::Class::Core';
 | |
| 
 | |
| __PACKAGE__->table_class('DBIx::Class::ResultSource::View');
 | |
| 
 | |
| __PACKAGE__->table('device_port_speed');
 | |
| __PACKAGE__->result_source_instance->is_virtual(1);
 | |
| __PACKAGE__->result_source_instance->view_definition(<<ENDSQL
 | |
|   SELECT ip,
 | |
|          sum( COALESCE(dpp.raw_speed,1) ) as total
 | |
|   FROM device_port
 | |
|   LEFT OUTER JOIN device_port_properties dpp USING (ip, port)
 | |
|   WHERE type = 'ethernetCsmacd'
 | |
|     AND speed LIKE '%bps'
 | |
|   GROUP BY ip
 | |
|   ORDER BY total DESC
 | |
| ENDSQL
 | |
| );
 | |
| 
 | |
| __PACKAGE__->add_columns(
 | |
|   'total' => {
 | |
|     data_type => 'integer',
 | |
|   },
 | |
| );
 | |
| 
 | |
| __PACKAGE__->belongs_to('device', 'App::Netdisco::DB::Result::Device',
 | |
|   { 'foreign.ip' => 'self.ip' });
 | |
| 
 | |
| 1;
 |