diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2022-12-08 18:22:09 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2022-12-08 18:22:09 +0100 |
commit | 115e07f35c8bbd7409f32aa7f9f89fe222a67b0f (patch) | |
tree | a43eb26875adfbcf07cb8b60777a3aa2b0f65242 /lib/Travelynx/Model/Stations.pm | |
parent | afedcef2663ceda6d4a9b88af702c04eb4eb0f4a (diff) |
move grep_unknown_stations to Stations model
Diffstat (limited to 'lib/Travelynx/Model/Stations.pm')
-rw-r--r-- | lib/Travelynx/Model/Stations.pm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Travelynx/Model/Stations.pm b/lib/Travelynx/Model/Stations.pm index 6c898b1..62504d3 100644 --- a/lib/Travelynx/Model/Stations.pm +++ b/lib/Travelynx/Model/Stations.pm @@ -62,6 +62,16 @@ sub get_by_name { } # Slow +sub get_by_names { + my ( $self, @names ) = @_; + + my @ret + = $self->{pg}->db->select( 'stations', '*', { name => { '=', \@names } } ) + ->hashes->each; + return @ret; +} + +# Slow sub get_by_ds100 { my ( $self, $ds100, %opt ) = @_; @@ -85,4 +95,14 @@ sub search { // $self->get_by_name( $identifier, %opt ); } +# Slow +sub grep_unknown { + my ( $self, @stations ) = @_; + + my %station = map { $_->{name} => 1 } $self->get_by_names(@stations); + my @unknown_stations = grep { not $station{$_} } @stations; + + return @unknown_stations; +} + 1; |