first part of the fix for #514
select distinct needs to be provided with an explicit order to return consistent results. ip & active suffices for nodes, but if it's a device with an entry in node_ip we get random results. so also order on boolean node to prefer device entries in that case.
(at the time of writing however none of my devices return a mac address, which might be another bug)
It would seem like we'd want for this to be distinct mac addresses here right? Otherwise you'd could get duplicate counters. In our environment where things move around this makes for repeat lines in the nodes table. To get a true inventory count I'd think this should only count unique macs. Apologies if this is NOT the desired output for this module.