summaryrefslogtreecommitdiff
path: root/lib/Travelynx
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-05-18 17:10:53 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-05-18 17:10:53 +0200
commite68043b8fb840bad3091f53f5e9adca3451d40d1 (patch)
tree351818a9ff0ec03079b01374a96ea9368066b633 /lib/Travelynx
parentb4676c11fbb6893558f3c168183786e666b3ae72 (diff)
Show arrival/departure platform in journey card
Diffstat (limited to 'lib/Travelynx')
-rw-r--r--lib/Travelynx/Command/database.pm54
-rw-r--r--lib/Travelynx/Command/work.pm2
2 files changed, 56 insertions, 0 deletions
diff --git a/lib/Travelynx/Command/database.pm b/lib/Travelynx/Command/database.pm
index 11a946e..a15390d 100644
--- a/lib/Travelynx/Command/database.pm
+++ b/lib/Travelynx/Command/database.pm
@@ -481,6 +481,60 @@ my @migrations = (
}
);
},
+
+ # v11 -> v12
+ sub {
+ my ($db) = @_;
+ $db->query(
+ qq{
+ alter table journeys
+ add column dep_platform varchar(16),
+ add column arr_platform varchar(16);
+ alter table in_transit
+ add column dep_platform varchar(16),
+ add column arr_platform varchar(16);
+ create or replace view journeys_str as select
+ journeys.id as journey_id, user_id,
+ train_type, train_line, train_no, train_id,
+ extract(epoch from checkin_time) as checkin_ts,
+ extract(epoch from sched_departure) as sched_dep_ts,
+ extract(epoch from real_departure) as real_dep_ts,
+ dep_stations.ds100 as dep_ds100,
+ dep_stations.name as dep_name,
+ extract(epoch from checkout_time) as checkout_ts,
+ extract(epoch from sched_arrival) as sched_arr_ts,
+ extract(epoch from real_arrival) as real_arr_ts,
+ arr_stations.ds100 as arr_ds100,
+ arr_stations.name as arr_name,
+ cancelled, edited, route, messages,
+ dep_platform, arr_platform
+ from journeys
+ join stations as dep_stations on dep_stations.id = checkin_station_id
+ join stations as arr_stations on arr_stations.id = checkout_station_id
+ ;
+ create or replace view in_transit_str as select
+ user_id,
+ train_type, train_line, train_no, train_id,
+ extract(epoch from checkin_time) as checkin_ts,
+ extract(epoch from sched_departure) as sched_dep_ts,
+ extract(epoch from real_departure) as real_dep_ts,
+ dep_stations.ds100 as dep_ds100,
+ dep_stations.name as dep_name,
+ extract(epoch from checkout_time) as checkout_ts,
+ extract(epoch from sched_arrival) as sched_arr_ts,
+ extract(epoch from real_arrival) as real_arr_ts,
+ arr_stations.ds100 as arr_ds100,
+ arr_stations.name as arr_name,
+ cancelled, route, messages,
+ dep_platform, arr_platform
+ from in_transit
+ join stations as dep_stations on dep_stations.id = checkin_station_id
+ left join stations as arr_stations on arr_stations.id = checkout_station_id
+ ;
+ update schema_version set version = 12;
+ }
+ );
+ },
);
sub setup_db {
diff --git a/lib/Travelynx/Command/work.pm b/lib/Travelynx/Command/work.pm
index 6c84d49..a9969f3 100644
--- a/lib/Travelynx/Command/work.pm
+++ b/lib/Travelynx/Command/work.pm
@@ -45,6 +45,7 @@ sub run {
$db->update(
'in_transit',
{
+ dep_platform => $train->platform,
real_departure => $train->departure,
route => join( '|', $train->route ),
messages => join(
@@ -95,6 +96,7 @@ sub run {
$db->update(
'in_transit',
{
+ arr_platform => $train->platform,
sched_arrival => $train->sched_arrival,
real_arrival => $train->arrival,
route => join( '|', $train->route ),