Unverified Commit 3c25dd53 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

dbris, efa, hafas: keep track of latest update; show hint if old

parent f0155195
Loading
Loading
Loading
Loading
+29 −3
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ sub add {
				data               => $json->encode(
					{
						rt          => $stop->rt_dep ? 1 : 0,
						last_update => $now->epoch,
						%{ $data // {} }
					}
				),
@@ -252,6 +253,7 @@ sub add {
				data               => $json->encode(
					{
						rt          => $stop->{rt_dep} ? 1 : 0,
						last_update => $now->epoch,
						%{ $data // {} }
					}
				),
@@ -355,6 +357,7 @@ sub add {
				data               => $json->encode(
					{
						rt          => $stop->{rt_dep} ? 1 : 0,
						last_update => $now->epoch,
						%{ $data // {} }
					}
				),
@@ -534,6 +537,11 @@ sub postprocess {
	$ret->{comment}            = $ret->{user_data}{comment};
	$ret->{wagongroups}        = $ret->{user_data}{wagongroups};

	if ( $ret->{extra_data}{last_update} ) {
		$ret->{last_update} = epoch_to_dt( $ret->{extra_data}{last_update} );
		$ret->{last_update_delta} = $now->epoch - $ret->{last_update}->epoch;
	}

	if ( $ret->{sched_dep_ts} and $ret->{real_dep_ts} ) {
		$ret->{dep_delay} = $ret->{real_dep_ts} - $ret->{sched_dep_ts};
	}
@@ -1051,6 +1059,9 @@ sub update_departure_dbris {
		$ephemeral_data->{rt} = 1;
	}

	$ephemeral_data->{last_update}
	  = DateTime->now( time_zone => 'Europe/Berlin' )->epoch;

	$ephemeral_data->{him_msg}  = [];
	$persistent_data->{him_msg} = [];
	for my $msg ( $journey->messages ) {
@@ -1109,6 +1120,9 @@ sub update_departure_efa {
		$ephemeral_data->{rt} = 1;
	}

	$ephemeral_data->{last_update}
	  = DateTime->now( time_zone => 'Europe/Berlin' )->epoch;

	# 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
	# this case, the new train would receive data from the previous journey.
@@ -1171,6 +1185,9 @@ sub update_departure_hafas {
		$ephemeral_data->{rt} = 1;
	}

	$ephemeral_data->{last_update}
	  = DateTime->now( time_zone => 'Europe/Berlin' )->epoch;

	# 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
	# this case, the new train would receive data from the previous journey.
@@ -1250,6 +1267,9 @@ sub update_arrival_dbris {
		$ephemeral_data->{rt} = 1;
	}

	$ephemeral_data->{last_update}
	  = DateTime->now( time_zone => 'Europe/Berlin' )->epoch;

	$ephemeral_data->{him_msg}  = [];
	$persistent_data->{him_msg} = [];
	for my $msg ( $journey->messages ) {
@@ -1346,6 +1366,9 @@ sub update_arrival_efa {
		$ephemeral_data->{rt} = 1;
	}

	$ephemeral_data->{last_update}
	  = DateTime->now( time_zone => 'Europe/Berlin' )->epoch;

	my @route;
	for my $j_stop ( $journey->route ) {
		push(
@@ -1468,6 +1491,9 @@ sub update_arrival_hafas {
		$ephemeral_data->{rt} = 1;
	}

	$ephemeral_data->{last_update}
	  = DateTime->now( time_zone => 'Europe/Berlin' )->epoch;

	my @route;
	for my $j_stop ( $journey->route ) {
		push(
+21 −1
Original line number Diff line number Diff line
@@ -2,7 +2,10 @@
<div class="autorefresh">
	<div class="card">
		<div class="card-content">
			<i class="material-icons right sync-failed-marker grey-text" style="display: none;">sync_problem</i>
			<i class="material-icons right sync-failed-marker grey-text" style="display: none;">cloud_off</i>
			% if ($journey->{last_update_delta} and $journey->{last_update_delta} > 300) {
				<i class="material-icons right grey-text">sync_problem</i>
			% }
			% if (not $journey->{arr_name}) {
				<span class="card-title center-align"><%= L('status.select-destination') %></span>
			% }
@@ -271,6 +274,23 @@
					% }
				</p>
			% }
			% if ($journey->{last_update_delta} and $journey->{last_update_delta} > 300) {
				<p class="grey-text" style="margin-top: 2em;">
					<i class="material-icons left">warning</i>
					Echtzeitdaten wurden zuletzt um
					%= $journey->{last_update}->strftime('%H:%M')
					Uhr (vor mehr als
					%= int($journey->{last_update_delta} / 60)
					Minuten) aktualisiert.
					% if ($journey->{is_dbris}) {
						Wahrscheinlich wurde travelynx vom Backend blockiert.
					% }
					% else {
						Möglicherweise sind Teile von travelynx und/oder das
						genutzte Backend defekt.
					% }
				</p>
			% }
		</div>
		<div class="card-action">
			% if ($journey->{arr_name}) {