Move get_distinct_col to App::Netdisco::DB::ResultSet so it can be used in all ResultSet's

This commit is contained in:
Eric A. Miller
2014-02-08 20:40:05 -05:00
parent 1e2cc41b76
commit 8e8839dd43
2 changed files with 21 additions and 21 deletions

View File

@@ -8,4 +8,25 @@ use base 'DBIx::Class::ResultSet';
__PACKAGE__->load_components( __PACKAGE__->load_components(
qw{Helper::ResultSet::SetOperations Helper::ResultSet::Shortcut}); 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; 1;

View File

@@ -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 =head2 with_port_count
This is a modifier for any C<search()> which This is a modifier for any C<search()> which