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

history: show daily travel distances

parent 4724971c
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1658,6 +1658,12 @@ sub yearly_history {
		$with_review = 1;
	}

	my %km_by_day;
	for my $journey (@journeys) {
		my $mmdd = $journey->{sched_departure}->strftime('%m/%d');
		$km_by_day{$mmdd} += $journey->{distance} / 1e3;
	}

	$self->respond_to(
		json => {
			json => {
@@ -1669,6 +1675,7 @@ sub yearly_history {
			template    => 'history_by_year',
			title       => "travelynx: $year",
			journeys    => [@journeys],
			km_by_day   => \%km_by_day,
			year        => $year,
			have_review => $with_review,
			statistics  => $stats
@@ -1734,6 +1741,12 @@ sub monthly_history {

	my $month_name = $months[ $month - 1 ];

	my %km_by_day;
	for my $journey (@journeys) {
		my $mmdd = $journey->{sched_departure}->strftime('%m/%d');
		$km_by_day{$mmdd} += $journey->{distance} / 1e3;
	}

	$self->respond_to(
		json => {
			json => {
@@ -1745,6 +1758,7 @@ sub monthly_history {
			template    => 'history_by_month',
			title       => "travelynx: $month_name $year",
			journeys    => [@journeys],
			km_by_day   => \%km_by_day,
			year        => $year,
			month       => $month,
			month_name  => $month_name,
+3 −0
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@
			% if ($olddate ne $date) {
				<li class="collection-item history-date-change">
					<b><%= $date %></b>
					% if (my $km = (stash('km_by_day') // {})->{$travel->{sched_departure}->strftime('%m/%d')}) {
						<span style="float: right; font-weight: normal;"><%= sprintf('%.f km', $km) %></span>
					% }
				</li>
				% $olddate = $date
			% }
+1 −1
Original line number Diff line number Diff line
@@ -11,5 +11,5 @@
</div>

% if (stash('journeys')) {
	%= include '_history_trains', date_format => '%d.%m.', journeys => stash('journeys'), order => 'asc';
	%= include '_history_trains', date_format => '%d.%m.', journeys => stash('journeys'), km_by_day => stash('km_by_day'), order => 'asc';
% }
+1 −1
Original line number Diff line number Diff line
@@ -32,5 +32,5 @@
% }

% if (stash('journeys')) {
	%= include '_history_trains', date_format => '%d.%m.', journeys => stash('journeys'), order => 'asc';
	%= include '_history_trains', date_format => '%d.%m.', journeys => stash('journeys'), km_by_day => stash('km_by_day'), order => 'asc';
% }