Unverified Commit 45b1d164 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

InTransit: only set isCancelled when needed; also set isAdditional

parent 2cd698b8
Loading
Loading
Loading
Loading
+66 −41
Original line number Diff line number Diff line
@@ -158,7 +158,6 @@ sub add {
						sched_dep => _epoch( $j_stop->sched_dep ),
						rt_arr    => _epoch( $j_stop->rt_arr ),
						rt_dep    => _epoch( $j_stop->rt_dep ),
						isCancelled => $j_stop->is_cancelled,
						arr_delay => $j_stop->arr_delay,
						dep_delay => $j_stop->dep_delay,
						platform  => $j_stop->platform,
@@ -168,6 +167,9 @@ sub add {
					}
				]
			);
			if ( $j_stop->is_cancelled ) {
				$route[-1][2]{isCancelled} = 1;
			}
		}
		$persistent_data->{operator} = $journey->operator;
		$db->insert(
@@ -284,7 +286,6 @@ sub add {
						sched_dep => _epoch( $j_stop->sched_dep ),
						rt_arr    => _epoch( $j_stop->rt_arr ),
						rt_dep    => _epoch( $j_stop->rt_dep ),
						isCancelled => $j_stop->is_cancelled,
						arr_delay => $j_stop->arr_delay,
						dep_delay => $j_stop->dep_delay,
						platform  => $j_stop->platform,
@@ -297,6 +298,12 @@ sub add {
					}
				]
			);
			if ( $j_stop->is_additional ) {
				$route[-1][2]{isAdditional} = 1;
			}
			if ( $j_stop->is_cancelled ) {
				$route[-1][2]{isCancelled} = 1;
			}
		}
		my @messages;
		for my $msg ( $journey->messages ) {
@@ -517,6 +524,14 @@ sub postprocess {
	$ret->{comment}            = $ret->{user_data}{comment};
	$ret->{wagongroups}        = $ret->{user_data}{wagongroups};

	if ( $ret->{sched_dep_ts} and $ret->{real_dep_ts} ) {
		$ret->{dep_delay} = $ret->{real_dep_ts} - $ret->{sched_dep_ts};
	}

	if ( $ret->{sched_arr_ts} and $ret->{real_arr_ts} ) {
		$ret->{arr_delay} = $ret->{real_arr_ts} - $ret->{sched_arr_ts};
	}

	$ret->{platform_type} = 'Gleis';
	if ( $ret->{train_type} and $ret->{train_type} =~ m{ ast | bus | ruf }ix ) {
		$ret->{platform_type} = 'Steig';
@@ -1254,7 +1269,6 @@ sub update_arrival_dbris {
					rt_arr    => _epoch( $j_stop->rt_arr ),
					rt_dep    => _epoch( $j_stop->rt_dep ),
					platform  => $j_stop->platform,
					isCancelled => $j_stop->is_cancelled,
					arr_delay => $j_stop->arr_delay,
					dep_delay => $j_stop->dep_delay,
					platform  => $j_stop->platform,
@@ -1267,6 +1281,12 @@ sub update_arrival_dbris {
				}
			]
		);
		if ( $j_stop->is_additional ) {
			$route[-1][2]{isAdditional} = 1;
		}
		if ( $j_stop->is_cancelled ) {
			$route[-1][2]{isCancelled} = 1;
		}
	}

	# selecting on user_id and train_no avoids a race condition if a user checks
@@ -1322,7 +1342,6 @@ sub update_arrival_efa {
					sched_dep => _epoch( $j_stop->sched_dep ),
					rt_arr    => _epoch( $j_stop->rt_arr ),
					rt_dep    => _epoch( $j_stop->rt_dep ),
					isCancelled => $j_stop->is_cancelled,
					arr_delay => $j_stop->arr_delay,
					dep_delay => $j_stop->dep_delay,
					platform  => $j_stop->platform,
@@ -1332,7 +1351,13 @@ sub update_arrival_efa {
				}
			]
		);
		if ( $j_stop->is_cancelled ) {
			$route[-1][2]{isCancelled} = 1;
		}
	}

	# TODO set efa_load from old route entry if missing in current route entry
	# (at least in VVO, occupancy data is only provided for future stops)

	# selecting on user_id and train_no avoids a race condition if a user checks
	# into a new train while we are fetching data for their previous journey. In