Commit 257a4ec3 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Note that dbf is limited to DB lines when encountering no results

parent 254013b6
Loading
Loading
Loading
Loading
+24 −8
Original line number Diff line number Diff line
@@ -28,7 +28,9 @@ my %default = (
);

sub handle_no_results {
	my ( $self, $station, $errstr ) = @_;
	my ( $self, $station, $data ) = @_;

	my $errstr = $data->{errstr};

	my @candidates = map { [ $_->[1], $_->[0] ] }
	  Travel::Status::DE::IRIS::Stations::get_station($station);
@@ -43,17 +45,27 @@ sub handle_no_results {
		);
		return;
	}
	if ( $data->{station_ds100} and $data->{station_ds100} =~ m{ ^ [XYZ] }x ) {
		$self->render(
			'landingpage',
			error => ( $errstr // "Keine Abfahrten an '$station'" )
			  . '. Das von DBF genutzte IRIS-Backend unterstützt im Regelfall nur innerdeutsche Zugfahrten.',
			hide_opts => 0
		);
		return;
	}
	$self->render(
		'landingpage',
		error     => ( $errstr // "Got no results for '$station'" ),
		error     => ( $errstr // "Keine Abfahrten an '$station'" ),
		hide_opts => 0
	);
	return;
}

sub handle_no_results_json {
	my ( $self, $station, $errstr, $api_version ) = @_;
	my ( $self, $station, $data, $api_version ) = @_;

	my $errstr   = $data->{errstr};
	my $callback = $self->param('callback');

	$self->res->headers->access_control_allow_origin(q{*});
@@ -221,6 +233,8 @@ sub get_results_for {
		$data = {
			results => [ $status->results ],
			errstr  => $status->errstr,
			station_ds100 =>
			  ( $status->station ? $status->station->{ds100} : undef ),
			station_name =>
			  ( $status->station ? $status->station->{name} : $station ),
		};
@@ -318,15 +332,14 @@ sub handle_request {
	}

	my $data = get_results_for( $station, %opt );
	my $errstr = $data->{errstr};

	if ( not @{ $data->{results} } and $template eq 'json' ) {
		$self->handle_no_results_json( $station, $errstr, $api_version );
		$self->handle_no_results_json( $station, $data, $api_version );
		return;
	}

	if ( not @{ $data->{results} } ) {
		$self->handle_no_results( $station, $errstr );
		$self->handle_no_results( $station, $data );
		return;
	}

@@ -1104,7 +1117,10 @@ sub handle_result {
				# no longer supported
				$self->handle_no_results_json(
					undef,
					"JSON API version=${apiver} is no longer supported",
					{
						errstr =>
						  "JSON API version=${apiver} is no longer supported"
					},
					$Travel::Status::DE::IRIS::VERSION
				);
				return;
+2 −2
Original line number Diff line number Diff line
<div class="error"><strong>Fehler:</strong>
<pre>
<p style="font-family: Monospace;">
%= $error
</pre>
</p>
</div>
+2 −2
Original line number Diff line number Diff line
@@ -101,9 +101,9 @@
<div class="container">
% if (my $error = stash 'error') {
<div class="error"><strong>Fehler:</strong>
<pre>
<p>
%= $error
</pre>
</p>
</div>
% }
% elsif (stash('stationlist')) {