diff --git a/Netdisco/lib/App/Netdisco/DB/ResultSet.pm b/Netdisco/lib/App/Netdisco/DB/ResultSet.pm index c9272050..42a9d439 100644 --- a/Netdisco/lib/App/Netdisco/DB/ResultSet.pm +++ b/Netdisco/lib/App/Netdisco/DB/ResultSet.pm @@ -8,4 +8,25 @@ use base 'DBIx::Class::ResultSet'; __PACKAGE__->load_components( qw{Helper::ResultSet::SetOperations Helper::ResultSet::Shortcut}); +=head2 get_distinct_col( $column ) + +Returns an asciibetical sorted list of the distinct values in the given column +of the Device table. This is useful for web forms when you want to provide a +drop-down list of possible options. + +=cut + +sub get_distinct_col { + my ($rs, $col) = @_; + return $rs unless $col; + + return $rs->search({}, + { + columns => [$col], + order_by => $col, + distinct => 1 + } + )->get_column($col)->all; +} + 1; diff --git a/Netdisco/lib/App/Netdisco/DB/ResultSet/Device.pm b/Netdisco/lib/App/Netdisco/DB/ResultSet/Device.pm index 2f9dc9e9..54832d2c 100644 --- a/Netdisco/lib/App/Netdisco/DB/ResultSet/Device.pm +++ b/Netdisco/lib/App/Netdisco/DB/ResultSet/Device.pm @@ -518,27 +518,6 @@ sub get_releases { } -=head2 get_distinct_col( $column ) - -Returns an asciibetical sorted list of the distinct values in the given column -of the Device table. This is useful for web forms when you want to provide a -drop-down list of possible options. - -=cut - -sub get_distinct_col { - my ($rs, $col) = @_; - return $rs unless $col; - - return $rs->search({}, - { - columns => [$col], - order_by => $col, - distinct => 1 - } - )->get_column($col)->all; -} - =head2 with_port_count This is a modifier for any C which