summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-12-03 22:15:09 +0100
committerDaniel Friesel <derf@finalrewind.org>2020-12-03 22:15:09 +0100
commit2613fc0e5896a03bb71f3cb8151f85b415fcab1f (patch)
tree8a4e3467d82251d9cd2ea99dfa4fd97e32d7b981
parent025b58126fb5cac92e0506e3364f342c8a9daf40 (diff)
use stats-enabled list view for year list as well1.18.12
-rwxr-xr-xlib/Travelynx/Model/Journeys.pm19
-rw-r--r--templates/_history_years.html.ep2
-rw-r--r--templates/history.html.ep4
3 files changed, 21 insertions, 4 deletions
diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm
index e09ca7d..e6659e2 100755
--- a/lib/Travelynx/Model/Journeys.pm
+++ b/lib/Travelynx/Model/Journeys.pm
@@ -703,7 +703,7 @@ sub get_latest_checkout_station_id {
return $res_h->{checkout_station_id};
}
-sub get_years {
+sub get_nav_years {
my ( $self, %opt ) = @_;
my $uid = $opt{uid};
@@ -723,6 +723,22 @@ sub get_years {
return @ret;
}
+sub get_years {
+ my ( $self, %opt ) = @_;
+
+ my @years = $self->get_nav_years(%opt);
+
+ for my $year (@years) {
+ my $stats = $self->stats_cache->get(
+ uid => $opt{uid},
+ year => $year,
+ month => 0,
+ );
+ $year->[2] = $stats // {};
+ }
+ return @years;
+}
+
sub get_months_for_year {
my ( $self, %opt ) = @_;
@@ -748,7 +764,6 @@ sub get_months_for_year {
for my $row ( $res->hashes->each ) {
if ( $row->{year} == $year ) {
- # TODO delegate query to the (not yet present) JourneyStats model
my $stats = $self->stats_cache->get(
db => $db,
uid => $uid,
diff --git a/templates/_history_years.html.ep b/templates/_history_years.html.ep
index 686908f..5591799 100644
--- a/templates/_history_years.html.ep
+++ b/templates/_history_years.html.ep
@@ -1,6 +1,6 @@
<div class="row">
<div class="col s12">
- % my @years = journeys->get_years(uid => current_user->{id});
+ % my @years = journeys->get_nav_years(uid => current_user->{id});
% if (@years) {
<ul class="pagination">
% for my $year (@years) {
diff --git a/templates/history.html.ep b/templates/history.html.ep
index 1752000..6b8c335 100644
--- a/templates/history.html.ep
+++ b/templates/history.html.ep
@@ -1,6 +1,8 @@
<h2>Fahrten</h2>
-%= include '_history_years', current => '';
+Für Details ein Jahr auswählen.
+
+%= include '_history_years_list';
<h2>Auswertungen</h2>
<div class="row">