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

review: link to list of all single-trip checkins

parent 09463d7d
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1514,6 +1514,7 @@ sub year_in_review {
sub yearly_history {
	my ($self) = @_;
	my $year   = $self->stash('year');
	my $filter = $self->param('filter');
	my @journeys;

	# DateTime is very slow when looking far into the future due to DST changes
@@ -1540,6 +1541,10 @@ sub yearly_history {
		with_datetime => 1
	);

	if ( $filter and $filter eq 'single' ) {
		@journeys = $self->journeys->grep_single(@journeys);
	}

	if ( not @journeys ) {
		$self->render( 'not_found',
			message => 'Keine Zugfahrten im angefragten Jahr gefunden.' );
+16 −0
Original line number Diff line number Diff line
@@ -1039,6 +1039,22 @@ sub get_travel_distance {
		$distance_beeline, $skipped );
}

sub grep_single {
	my ( $self, @journeys ) = @_;

	my %num_by_trip;
	for my $journey (@journeys) {
		if ( $journey->{from_name} and $journey->{to_name} ) {
			$num_by_trip{ $journey->{from_name} . '|' . $journey->{to_name} }
			  += 1;
		}
	}

	return
	  grep { $num_by_trip{ $_->{from_name} . '|' . $_->{to_name} } == 1 }
	  @journeys;
}

sub compute_review {
	my ( $self, $stats, @journeys ) = @_;
	my $longest_km;
+8 −0
Original line number Diff line number Diff line
@@ -23,6 +23,14 @@

%= include '_history_months_for_year';

% if (param('filter') and param('filter') eq 'single') {
<div class="row">
	<div class="col s12 m12 l12">
		<p>Die folgende Auflistung enthält nur Fahrten, deren Kombination aus Start und Ziel im aktuellen Jahr einmalig ist.</p>
	</div>
</div>
% }

% if (stash('journeys')) {
	%= include '_history_trains', date_format => '%d.%m.', journeys => stash('journeys');
% }
+1 −1
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@
				% }
				% if ($review->{single_trip_count}) {
					<p>
						<strong><%= $review->{single_trip_percent_h} %></strong> aller Verbindungen bist du nur genau <strong>einmal</strong> gefahren. Zum Beispiel:<br/>
						<a href="/history/<%= $year %>?filter=single"><strong><%= $review->{single_trip_percent_h} %></strong> aller Verbindungen</a> bist du nur genau <strong>einmal</strong> gefahren. Zum Beispiel:<br/>
						% for my $i (0 .. $#{$review->{single_trips}}) {
							% my $trip = $review->{single_trips}[$i];
							<%= $trip->[0] %> → <%= $trip->[1] %><br/>