summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-09-08 17:48:09 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-09-08 17:48:09 +0200
commit44cdac57eed0f02c8801ed85d08be4e7daead991 (patch)
treeaceca03a6158fa415302ca138865dfbfd9042c5f
parenteddc7b007631290b4569676d4b3e1019894858bb (diff)
move tripid generation to trainsearch helper
-rw-r--r--lib/DBInfoscreen/Controller/Map.pm27
-rw-r--r--lib/DBInfoscreen/Helper/HAFAS.pm12
2 files changed, 16 insertions, 23 deletions
diff --git a/lib/DBInfoscreen/Controller/Map.pm b/lib/DBInfoscreen/Controller/Map.pm
index 8a84e16..92f3644 100644
--- a/lib/DBInfoscreen/Controller/Map.pm
+++ b/lib/DBInfoscreen/Controller/Map.pm
@@ -868,20 +868,9 @@ sub search {
my $t1_data;
my $t2_data;
- my $now = DateTime->now( time_zone => 'Europe/Berlin' );
- my $date_yy = $now->strftime('%d.%m.%y');
- my $date_yyyy = $now->strftime('%d.%m.%Y');
-
- # Doesn't seem to matter -- so far, HAFAS is happy as long as the date part
- # starts with a number. HAFAS-internal tripIDs use this format (withouth
- # leading zero for day of month < 10) though, so let's stick with it.
- my $date_map = $now->strftime('%d%m%Y');
-
if ( $t1 and $t1 =~ m{^\S+\s+\d+$} ) {
$t1_data = $self->hafas->trainsearch(
- train_no => $t1,
- date_yy => $date_yy,
- date_yyyy => $date_yyyy
+ train_no => $t1,
);
}
else {
@@ -931,21 +920,13 @@ sub search {
}
if ( $t1 and not $t2 ) {
- $self->redirect_to(
- sprintf(
- "/map/1|%d|%d|%d|%s/0",
- $t1_data->{id}, $t1_data->{cycle},
- $t1_data->{pool}, $date_map
- )
- );
+ $self->redirect_to( sprintf( "/map/%s/0", $t1_data->{trip_id}, ) );
}
elsif ( $t1 and $t2 ) {
$self->redirect_to(
sprintf(
- "/intersection/1|%d|%d|%d|%s,0;1|%d|%d|%d|%s,0",
- $t1_data->{id}, $t1_data->{cycle}, $t1_data->{pool},
- $date_map, $t2_data->{id}, $t2_data->{cycle},
- $t2_data->{pool}, $date_map
+ "/intersection/%s,0;%s,0",
+ $t1_data->{trip_id}, $t2_data->{trip_id},
)
);
}
diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm
index 2eda72f..2eb156c 100644
--- a/lib/DBInfoscreen/Helper/HAFAS.pm
+++ b/lib/DBInfoscreen/Helper/HAFAS.pm
@@ -198,6 +198,18 @@ sub trainsearch {
}
}
+ if ($result) {
+
+ # The trip_id's date part doesn't seem to matter -- so far, HAFAS is
+ # happy as long as the date part starts with a number. HAFAS-internal
+ # tripIDs use this format (withouth leading zero for day of month < 10)
+ # though, so let's stick with it.
+ my $date_map = $opt{date_yyyy};
+ $date_map =~ tr{.}{}d;
+ $result->{trip_id} = sprintf( '1|%d|%d|%d|%s',
+ $result->{id}, $result->{cycle}, $result->{pool}, $date_map );
+ }
+
return $result;
}