From 8e8839dd43f7724efbad7791b59d681cc5fc1796 Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Sat, 8 Feb 2014 20:40:05 -0500 Subject: [PATCH] Move get_distinct_col to App::Netdisco::DB::ResultSet so it can be used in all ResultSet's --- Netdisco/lib/App/Netdisco/DB/ResultSet.pm | 21 +++++++++++++++++++ .../lib/App/Netdisco/DB/ResultSet/Device.pm | 21 ------------------- 2 files changed, 21 insertions(+), 21 deletions(-) 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