summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlib/Travelynx/Model/Journeys.pm6
-rw-r--r--templates/_history_months_for_year.html.ep4
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm
index 9330707..750c8b1 100755
--- a/lib/Travelynx/Model/Journeys.pm
+++ b/lib/Travelynx/Model/Journeys.pm
@@ -749,9 +749,9 @@ sub get_months_for_year {
month => $row->{month}
}
)->expand->hash;
- if ($stats) {
- $ret[ $row->{month} - 1 ][2] = $stats->{data};
- }
+
+ # undef -> no journeys for this month; empty hash -> no cached stats
+ $ret[ $row->{month} - 1 ][2] = $stats->{data} // {};
}
}
return @ret;
diff --git a/templates/_history_months_for_year.html.ep b/templates/_history_months_for_year.html.ep
index c6a64de..1d035ab 100644
--- a/templates/_history_months_for_year.html.ep
+++ b/templates/_history_months_for_year.html.ep
@@ -4,7 +4,9 @@
% for my $month (journeys->get_months_for_year(uid => current_user->{id}, year => $year)) {
% if (defined $month->[2]) {
<a class="collection-item" href="/history/<%= $month->[0] %>"><%= $month->[1] %>
- <span class="secondary-content"><%= sprintf('%.f', $month->[2]{km_route}) %> km</span>
+ % if (defined $month->[2]{km_route}) {
+ <span class="secondary-content"><%= sprintf('%.f', $month->[2]{km_route}) %> km</span>
+ % }
</a>
% }
% else {