From e168d9cd39c38b8e5a1994c8bf11376d26e9ea77 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 23 Apr 2019 18:08:07 +0200 Subject: Use one row per journey instead of split checkin/checkout entries Whether a user is in transit or not is now determined by an entry in the in_transit table instead of a dangling checkin. All completed journeys are stored in the "journeys" table. This does most of the work needed for automatic checkout. However, note that the corresponding worker process is not implemented yet. --- templates/_history_trains.html.ep | 72 ++++++++++++++++---------------- templates/departures.html.ep | 12 +++--- templates/edit_journey.html.ep | 2 +- templates/journey.html.ep | 2 +- templates/landingpage.html.ep | 86 +++++++++++++++++++++++++++++++++------ templates/layouts/default.html.ep | 2 +- 6 files changed, 117 insertions(+), 59 deletions(-) (limited to 'templates') diff --git a/templates/_history_trains.html.ep b/templates/_history_trains.html.ep index def83d6..2328285 100644 --- a/templates/_history_trains.html.ep +++ b/templates/_history_trains.html.ep @@ -11,46 +11,44 @@ % for my $travel (@{$journeys}) { - % if ($travel->{completed}) { - % my $detail_link = '/journey/' . current_user()->{id} . '-' . $travel->{ids}->[1]; - - <%= $travel->{sched_departure}->strftime('%d.%m.') %> - <%= $travel->{type} %> <%= $travel->{line} // $travel->{no} %> - - - % if (param('cancelled')) { - %= $travel->{sched_departure}->strftime('%H:%M') + % my $detail_link = '/journey/' . $travel->{id}; + + <%= $travel->{sched_departure}->strftime('%d.%m.') %> + <%= $travel->{type} %> <%= $travel->{line} // $travel->{no} %> + + + % if (param('cancelled')) { + %= $travel->{sched_departure}->strftime('%H:%M') + % } + % else { + <%= $travel->{rt_departure}->strftime('%H:%M') %> + % if ($travel->{sched_departure} != $travel->{rt_departure}) { + (<%= sprintf('%+d', ($travel->{rt_departure}->epoch - $travel->{sched_departure}->epoch) / 60) %>) % } - % else { - <%= $travel->{rt_departure}->strftime('%H:%M') %> - % if ($travel->{sched_departure} != $travel->{rt_departure}) { - (<%= sprintf('%+d', ($travel->{rt_departure}->epoch - $travel->{sched_departure}->epoch) / 60) %>) + % } +
+ <%= $travel->{from_name} %> +
+ + + + % if (param('cancelled') and $travel->{sched_arrival}->epoch != 0) { + %= $travel->{sched_arrival}->strftime('%H:%M') + % } + % else { + % if ($travel->{rt_arrival}->epoch == 0 and $travel->{sched_arrival}->epoch == 0) { + timer_off + % } else { + %= $travel->{rt_arrival}->strftime('%H:%M'); + % if ($travel->{sched_arrival} != $travel->{rt_arrival}) { + (<%= sprintf('%+d', ($travel->{rt_arrival}->epoch - $travel->{sched_arrival}->epoch) / 60) %>) % } % } -
- <%= $travel->{from_name} %> -
- - - - % if (param('cancelled') and $travel->{sched_arrival}->epoch != 0) { - %= $travel->{sched_arrival}->strftime('%H:%M') - % } - % else { - % if ($travel->{rt_arrival}->epoch == 0 and $travel->{sched_arrival}->epoch == 0) { - timer_off - % } else { - %= $travel->{rt_arrival}->strftime('%H:%M'); - % if ($travel->{sched_arrival} != $travel->{rt_arrival}) { - (<%= sprintf('%+d', ($travel->{rt_arrival}->epoch - $travel->{sched_arrival}->epoch) / 60) %>) - % } - % } - % } -
- <%= $travel->{to_name} %> -
- - % } + % } +
+ <%= $travel->{to_name} %> + + % } diff --git a/templates/departures.html.ep b/templates/departures.html.ep index 1240d1d..7d33417 100644 --- a/templates/departures.html.ep +++ b/templates/departures.html.ep @@ -6,10 +6,10 @@
Aktuell eingecheckt

In <%= $status->{train_type} %> <%= $status->{train_no} %> - ab <%= $status->{station_name} %>

+ ab <%= $status->{dep_name} %>

- + Hier auschecken
@@ -20,10 +20,10 @@
Ausgecheckt

Aus <%= $status->{train_type} %> <%= $status->{train_no} %> - bis <%= $status->{station_name} %>

+ bis <%= $status->{arr_name} %>

- + undo Rückgängig?
@@ -38,8 +38,8 @@ – Zug auswählen zum Einchecken. % } % else { - – Keine Abfahrten gefunden. Ein Checkin ist frühestens 10 Minuten vor - und maximal 180 Minuten nach Abfahrt möglich. + – Keine Abfahrten gefunden. Ein Checkin ist frühestens 30 Minuten vor + und maximal 120 Minuten nach Abfahrt möglich. % }
diff --git a/templates/edit_journey.html.ep b/templates/edit_journey.html.ep index 0418d52..c37adba 100644 --- a/templates/edit_journey.html.ep +++ b/templates/edit_journey.html.ep @@ -80,7 +80,7 @@
diff --git a/templates/journey.html.ep b/templates/journey.html.ep index 1e0ccc7..4af9694 100644 --- a/templates/journey.html.ep +++ b/templates/journey.html.ep @@ -161,7 +161,7 @@
delete_forever diff --git a/templates/landingpage.html.ep b/templates/landingpage.html.ep index 5f69fd1..cd14f5c 100644 --- a/templates/landingpage.html.ep +++ b/templates/landingpage.html.ep @@ -14,26 +14,84 @@
% my $status = get_user_status(); + % my $now = DateTime->now(time_zone => 'Europe/Berlin'); + % my $dep_wait = ($status->{real_departure}->epoch - $now->epoch)/60; + % my $arr_wait = undef; + % if ($status->{real_arrival}->epoch) { + % $arr_wait = ($status->{real_arrival}->epoch - $now->epoch)/60; + % } % if ($status->{checked_in}) {
- Hallo, <%= current_user()->{name} %>! -

Du bist gerade eingecheckt in - <%= $status->{train_type} %> <%= $status->{train_no} %> - ab <%= $status->{station_name} %>. - % if ($status->{timestamp_delta} < 180) { - undo Rückgängig + Eingecheckt +

+ In <%= $status->{train_type} %> <%= $status->{train_no} %> + % if ($status->{arr_name}) { + von <%= $status->{dep_name} %> nach <%= $status->{arr_name} %>. % } -

-

Bei Ankunft: Station auswählen zum Auschecken.

+ % else { + ab <%= $status->{dep_name} %>. + % } +

+

+ Abfahrt + % if ($dep_wait > 0) { + in <%= int(($status->{real_departure}->epoch - $now->epoch)/60) %> Minute<%= $dep_wait >= 2 ? 'n' : '' %> + % } + um <%= $status->{real_departure}->strftime('%H:%M') %> + % if ($status->{real_departure}->epoch != $status->{sched_departure}->epoch) { + (+<%= int(($status->{real_departure}->epoch - $status->{sched_departure}->epoch)/60) %>) + % } +

+

+ % if ($status->{real_arrival}->epoch) { + Voraussichtliche Ankunft um <%= $status->{real_arrival}->strftime('%H:%M') %> + % if ($status->{real_arrival}->epoch != $status->{sched_arrival}->epoch) { + (+<%= int(($status->{real_arrival}->epoch - $status->{sched_arrival}->epoch)/60) %>) + % } + % } + % else { + Ankunft: noch nicht bekannt + % } +

+

+ Achtung: Automatischer Checkout ist noch nicht + implementiert. Bitte spätestens eine Stunde nach Ankunft + am Ziel manuell auschecken. +

+ % if ($status->{arr_name}) { +

Zielstation ändern?

+ % } + % else { +

Zielstation wählen:

+ % }
% my $is_after = 0; % for my $station (@{$status->{route_after}}) { - + % if ($status->{arr_name} and $station eq $status->{arr_name}) { + + % } + % else { + + % } % }
<%= $station %>
<%= $station %>
<%= $station %>
+ % if ($status->{arr_name}) { +

+ Falls das Backend ausgefallen ist oder der Zug aus anderen + Gründen verloren ging: Ohne Echtzeitdaten in <%= $status->{arr_name} %> + auschecken. +

+ % } + +
+ + undo Checkin Rückgängig? +
% } @@ -44,9 +102,6 @@

Prinzipiell wärest du nun eingecheckt in <%= $status->{train_type} %> <%= $status->{train_no} %> ab <%= $status->{station_name} %>, doch dieser Zug fällt aus. - % if ($status->{timestamp_delta} < 180) { - undo Checkinversuch rückgängig - % }

Falls du den Zugausfall z.B. für ein Fahrgastrechteformular dokumentieren möchtest, wähle bitte jetzt deine geplante @@ -62,6 +117,11 @@ +

+ + undo Checkinversuch Rückgängig? + +
% } % else { @@ -91,7 +151,7 @@

Letzte Fahrten

- %= include '_history_trains', journeys => [get_user_travels(limit => 1)]; + %= include '_history_trains', journeys => [get_user_travels(limit => 5)]; % } % else {
diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index 9ab9269..cdd624a 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -5,7 +5,7 @@ - % my $av = 'v5'; # asset version + % my $av = 'v6'; # asset version %= stylesheet "/static/${av}/css/materialize.min.css" %= stylesheet "/static/${av}/css/material-icons.css" %= stylesheet "/static/${av}/css/local.css" -- cgit v1.2.3