summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Model/Stations.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travelynx/Model/Stations.pm')
-rw-r--r--lib/Travelynx/Model/Stations.pm34
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/Travelynx/Model/Stations.pm b/lib/Travelynx/Model/Stations.pm
index c6d9730..6c647ec 100644
--- a/lib/Travelynx/Model/Stations.pm
+++ b/lib/Travelynx/Model/Stations.pm
@@ -461,11 +461,16 @@ sub get_by_name {
# Slow
sub get_by_names {
- my ( $self, @names ) = @_;
+ my ( $self, %opt ) = @_;
- my @ret
- = $self->{pg}->db->select( 'stations', '*', { name => { '=', \@names } } )
- ->hashes->each;
+ my @ret = $self->{pg}->db->select(
+ 'stations',
+ '*',
+ {
+ name => { '=', $opt{names} },
+ source => $opt{backend_id}
+ }
+ )->hashes->each;
return @ret;
}
@@ -506,12 +511,27 @@ sub search {
# Slow
sub grep_unknown {
- my ( $self, @stations ) = @_;
+ my ( $self, %opt ) = @_;
- my %station = map { $_->{name} => 1 } $self->get_by_names(@stations);
- my @unknown_stations = grep { not $station{$_} } @stations;
+ my %station = map { $_->{name} => 1 } $self->get_by_names(%opt);
+ my @unknown_stations = grep { not $station{$_} } @{ $opt{names} };
return @unknown_stations;
}
+sub get_bahn_stationinfo {
+ my ( $self, %opt ) = @_;
+ $opt{db} //= $self->{pg}->db;
+
+ my $res
+ = $opt{db}
+ ->select( 'bahn_platform_directions', ['data'], { eva => $opt{eva} } )
+ ->expand->hash;
+
+ if ($res) {
+ return $res->{data};
+ }
+ return;
+}
+
1;