Commit 335ab820 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

statistics: Add interchange wait time and journey count

parent 8d843dc4
Loading
Loading
Loading
Loading
+30 −15
Original line number Diff line number Diff line
@@ -956,11 +956,8 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
					$raw_messages
				) = @row;

				if (
					$action == $match_actions[0]
					or
					( $opt{checkout_id} and not @travels )
				  )
				if ( $action == $match_actions[0]
					or ( $opt{checkout_id} and not @travels ) )
				{
					push(
						@travels,
@@ -1167,12 +1164,14 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
			my $min_travel_real  = 0;
			my $delay_dep        = 0;
			my $delay_arr        = 0;
			my $interchange_real = 0;
			my $num_trains       = 0;
			my $num_journeys     = 0;

			my $next_departure = 0;

			for my $journey (@journeys) {
				$num_trains++;
				$num_journeys++;
				$km_route   += $journey->{km_route};
				$km_beeline += $journey->{km_beeline};
				if ( $journey->{sched_duration} > 0 ) {
@@ -1192,6 +1191,21 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
					  += (  $journey->{rt_arrival}->epoch
						  - $journey->{sched_arrival}->epoch ) / 60;
				}

				# Note that journeys are sorted from recent to older entries
				if (    $journey->{rt_arrival}
					and $next_departure
					and $next_departure - $journey->{rt_arrival}->epoch
					< ( 60 * 60 ) )
				{
					$interchange_real
					  += ( $next_departure - $journey->{rt_arrival}->epoch )
					  / 60;
				}
				else {
					$num_journeys++;
				}
				$next_departure = $journey->{rt_departure}->epoch;
			}
			return {
				km_route             => $km_route,
@@ -1200,6 +1214,7 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
				num_journeys         => $num_journeys,
				min_travel_sched     => $min_travel_sched,
				min_travel_real      => $min_travel_real,
				min_interchange_real => $interchange_real,
				delay_dep            => $delay_dep,
				delay_arr            => $delay_arr,
			};
+8 −0
Original line number Diff line number Diff line
@@ -22,6 +22,10 @@
			<table class="striped">
				<tr>
					<th scope="row">Fahrten</th>
					<td><%= $stats->{num_journeys} %></td>
				</tr>
				<tr>
					<th scope="row">Züge</th>
					<td><%= $stats->{num_trains} %></td>
				</tr>
				<tr>
@@ -34,6 +38,10 @@
					<td><%= sprintf('%02d:%02d', $stats->{min_travel_real} / 60, $stats->{min_travel_real} % 60) %> Stunden
						(nach Fahrplan: <%= sprintf('%02d:%02d', $stats->{min_travel_sched} / 60, $stats->{min_travel_sched} % 60) %>)<td>
				</tr>
				<tr>
					<th scope="row">Wartezeit (nur Umstiege)</th>
					<td><%= sprintf('%02d:%02d', $stats->{min_interchange_real} / 60, $stats->{min_interchange_real} % 60) %> Stunden
				</tr>
				<tr>
					<th scope="row">Kumulierte Verspätung</th>
					<td>Bei Abfahrt: <%= sprintf('%02d:%02d', $stats->{delay_dep} / 60, $stats->{delay_dep} % 60) %> Stunden<br/>