[#181] AP Client Count report was broken
The DB query was joining on the device_port_wireless table which as any fule kno isn't using the device port subinterface name so there would always be zero results (as wireless data is related to the subinterface). Fixed the query to use the device_port_ssid table, and also added a dedicated template so additional data can be displayed in the report.
This commit is contained in:
@@ -195,6 +195,20 @@ __PACKAGE__->might_have(
|
||||
}
|
||||
);
|
||||
|
||||
=head2 ssid
|
||||
|
||||
Returns a row from the C<device_port_ssid> table if one refers to this
|
||||
device port.
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->might_have(
|
||||
ssid => 'App::Netdisco::DB::Result::DevicePortSsid',
|
||||
{ 'foreign.ip' => 'self.ip',
|
||||
'foreign.port' => 'self.port',
|
||||
}
|
||||
);
|
||||
|
||||
=head2 wireless
|
||||
|
||||
Returns a row from the C<device_port_wireless> table if one refers to this
|
||||
|
||||
@@ -47,5 +47,21 @@ __PACKAGE__->belongs_to( port => 'App::Netdisco::DB::Result::DevicePort', {
|
||||
'foreign.ip' => 'self.ip', 'foreign.port' => 'self.port',
|
||||
});
|
||||
|
||||
=head2 nodes
|
||||
|
||||
Returns the set of Nodes whose MAC addresses are associated with this Device
|
||||
Port SSID.
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->has_many( nodes => 'App::Netdisco::DB::Result::Node',
|
||||
{
|
||||
'foreign.switch' => 'self.ip',
|
||||
'foreign.port' => 'self.port',
|
||||
},
|
||||
{ join_type => 'LEFT',
|
||||
cascade_copy => 0, cascade_update => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
# You can replace this text with custom code or comments, and it will be preserved on regeneration
|
||||
1;
|
||||
|
||||
@@ -18,15 +18,16 @@ get '/ajax/content/report/apclients' => require_login sub {
|
||||
my @results = schema('netdisco')->resultset('Device')->search(
|
||||
{ 'nodes.time_last' => { '>=', \'me.last_macsuck' } },
|
||||
{ select => [ 'ip', 'dns', 'name', 'model', 'location' ],
|
||||
join => { 'ports' => { 'wireless' => 'nodes' } },
|
||||
join => { 'ports' => { 'ssid' => 'nodes' } },
|
||||
'+columns' => [
|
||||
{ 'port' => 'ports.port' },
|
||||
{ 'description' => 'ports.name' },
|
||||
{ 'ssid' => 'ssid.ssid' },
|
||||
{ 'mac_count' => { count => 'nodes.mac' } },
|
||||
],
|
||||
group_by => [
|
||||
'me.ip', 'me.dns', 'me.name', 'me.model',
|
||||
'me.location', 'ports.port', 'ports.descr', 'ports.name'
|
||||
'me.location', 'ports.port', 'ports.descr', 'ports.name', 'ssid.ssid',
|
||||
],
|
||||
order_by => { -desc => [qw/count/] },
|
||||
}
|
||||
@@ -36,12 +37,12 @@ get '/ajax/content/report/apclients' => require_login sub {
|
||||
|
||||
if ( request->is_ajax ) {
|
||||
my $json = to_json( \@results );
|
||||
template 'ajax/report/portmultinodes.tt', { results => $json },
|
||||
template 'ajax/report/apclients.tt', { results => $json },
|
||||
{ layout => undef };
|
||||
}
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/report/portmultinodes_csv.tt',
|
||||
template 'ajax/report/apclients_csv.tt',
|
||||
{ results => \@results },
|
||||
{ layout => undef };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user