From 0bca47ae5628540e67e88f0a69fbc97a6d4c3fea Mon Sep 17 00:00:00 2001 From: Stefan Horst Date: Fri, 12 Aug 2016 13:56:02 +0200 Subject: added Train types parameter --- index.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.pl b/index.pl index aaa0acf..cd41aa4 100644 --- a/index.pl +++ b/index.pl @@ -319,6 +319,7 @@ sub handle_request { my $with_related = $self->param('recursive') // 0; my $callback = $self->param('callback'); my $apiver = $self->param('version') // 0; + my @train_types = split( /,/, $self->param('train_types') // q{} ); my %opt; my $api_version @@ -401,6 +402,7 @@ sub handle_request { for my $result (@results) { my $platform = ( split( / /, $result->platform ) )[0]; my $line = $result->line; + my $train_type = $result->type; my $delay = $result->delay; if ( $via and $result->can('route_post') ) { $via =~ s{ , \s* }{|}gx; @@ -418,6 +420,10 @@ sub handle_request { { next; } + if ( @train_types and not ( List::MoreUtils::any { $train_type =~ m{^$_} } @train_types )) + { + next; + } if ( $backend eq 'iris' and $admode eq 'arr' and not $result->arrival ) { next; -- cgit v1.2.3 From f3771b96629934360e8c99ff949a3c523b29fd13 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 12 Aug 2016 15:52:21 +0200 Subject: perltidy --- index.pl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/index.pl b/index.pl index cd41aa4..7ac24b6 100644 --- a/index.pl +++ b/index.pl @@ -319,7 +319,7 @@ sub handle_request { my $with_related = $self->param('recursive') // 0; my $callback = $self->param('callback'); my $apiver = $self->param('version') // 0; - my @train_types = split( /,/, $self->param('train_types') // q{} ); + my @train_types = split( /,/, $self->param('train_types') // q{} ); my %opt; my $api_version @@ -400,10 +400,10 @@ sub handle_request { } for my $result (@results) { - my $platform = ( split( / /, $result->platform ) )[0]; - my $line = $result->line; - my $train_type = $result->type; - my $delay = $result->delay; + my $platform = ( split( / /, $result->platform ) )[0]; + my $line = $result->line; + my $train_type = $result->type; + my $delay = $result->delay; if ( $via and $result->can('route_post') ) { $via =~ s{ , \s* }{|}gx; my @route = $result->route_post; @@ -420,7 +420,9 @@ sub handle_request { { next; } - if ( @train_types and not ( List::MoreUtils::any { $train_type =~ m{^$_} } @train_types )) + if ( @train_types + and + not( List::MoreUtils::any { $train_type =~ m{^$_} } @train_types ) ) { next; } -- cgit v1.2.3