Commit a48352ad authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

also show train direction on departure

parent ff75b16b
Loading
Loading
Loading
Loading
+53 −3
Original line number Diff line number Diff line
@@ -1744,7 +1744,7 @@ sub startup {

			my $journey = $db->select(
				'in_transit_str',
				[ 'arr_ds100', 'route' ],
				[ 'arr_ds100', 'dep_ds100', 'route' ],
				{ user_id => $uid }
			)->expand->hash;

@@ -1911,6 +1911,27 @@ sub startup {
				)->wait;
			}

			if ($is_departure) {
				$self->get_dbdb_station_p( $journey->{dep_ds100} )->then(
					sub {
						my ($station_info) = @_;

						my $res = $db->select( 'in_transit', ['data'],
							{ user_id => $uid } );
						my $res_h = $res->expand->hash;
						my $data  = $res_h->{data} // {};

						$data->{stationinfo_dep} = $station_info;

						$db->update(
							'in_transit',
							{ data    => JSON->new->encode($data) },
							{ user_id => $uid }
						);
					}
				)->wait;
			}

			if ( $journey->{arr_ds100} and not $is_departure ) {
				$self->get_dbdb_station_p( $journey->{arr_ds100} )->then(
					sub {
@@ -2271,8 +2292,12 @@ sub startup {

	$self->helper(
		'stationinfo_to_direction' => sub {
			my ( $self, $platform_info, $wagonorder, $prev_stop ) = @_;
			my ( $self, $platform_info, $wagonorder, $prev_stop, $next_stop )
			  = @_;
			if ( $platform_info->{kopfgleis} ) {
				if ($next_stop) {
					return $platform_info->{direction} eq 'r' ? 'l' : 'r';
				}
				return $platform_info->{direction};
			}
			elsif ( $prev_stop
@@ -2280,6 +2305,13 @@ sub startup {
			{
				return $platform_info->{direction_from}{$prev_stop};
			}
			elsif ( $next_stop
				and exists $platform_info->{direction_from}{$next_stop} )
			{
				return $platform_info->{direction_from}{$next_stop} eq 'r'
				  ? 'l'
				  : 'r';
			}
			elsif ($wagonorder) {
				my $wr;
				eval {
@@ -2349,6 +2381,7 @@ sub startup {
						$is_after = 1;
					}
				}
				my $stop_after_dep = $route_after[0][0];

				my $ts = $in_transit->{checkout_ts}
				  // $in_transit->{checkin_ts};
@@ -2464,6 +2497,22 @@ sub startup {
						$ret->{journey_completion} = 0;
					}

					my ($dep_platform_number)
					  = ( ( $ret->{dep_platform} // 0 ) =~ m{(\d+)} );
					if ( $dep_platform_number
						and exists $in_transit->{data}{stationinfo_dep}
						{$dep_platform_number} )
					{
						$ret->{dep_direction}
						  = $self->stationinfo_to_direction(
							$in_transit->{data}{stationinfo_dep}
							  {$dep_platform_number},
							$in_transit->{data}{wagonorder_dep},
							undef,
							$stop_after_dep
						  );
					}

					my ($arr_platform_number)
					  = ( ( $ret->{arr_platform} // 0 ) =~ m{(\d+)} );
					if ( $arr_platform_number
@@ -2475,7 +2524,8 @@ sub startup {
							$in_transit->{data}{stationinfo_arr}
							  {$arr_platform_number},
							$in_transit->{data}{wagonorder_arr},
							$stop_before_dest
							$stop_before_dest,
							undef
						  );
					}

+9 −1
Original line number Diff line number Diff line
@@ -42,8 +42,16 @@
					Ankunft in mehr als zwei Stunden
				% }
				% if ($journey->{departure_countdown} > 0 and $journey->{dep_platform}) {
					% if ($journey->{dep_direction} and $journey->{dep_direction} eq 'r') {
						<br/>Gleis <%= $journey->{dep_platform} %> ▶
					% }
					% elsif ($journey->{dep_direction} and $journey->{dep_direction} eq 'l') {
						<br/>◀ Gleis <%= $journey->{dep_platform} %>
					% }
					% else {
						<br/>von Gleis <%= $journey->{dep_platform} %>
					% }
				% }
				% if (my $wr = $journey->{wagonorder}) {
					<br/>
					<a href="https://marudor.de/<%= $journey->{dep_name} %>?selectedDetail=<%= $journey->{train_id} %>">