diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-06-09 13:13:56 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-06-09 13:13:56 +0200 |
commit | ccdfc0206f849ccaeee8f5a5093c51d1274d2652 (patch) | |
tree | a30deb0179ef95a01360161020dd85dfe1d1823d /lib/Travelynx/Model/Journeys.pm | |
parent | 3322ca23669871fff79a229b9167f2e3169c4352 (diff) |
Add (possibly still somewhat experimental) MOTIS support
Squashed commit of the following:
commit c7c8b2ec5d8254eefb548bfe7763a7d8c9558be4
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Mon Jun 9 13:08:57 2025 +0200
fix another merge issue
commit d2ae55c901ab59284263ad3070ba425e03cee833
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Mon Jun 9 13:08:39 2025 +0200
Stations: get_by_external_id is a slow function
commit 725174413300e71c350d2f1dcfbeacd751def977
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Mon Jun 9 13:05:48 2025 +0200
... I accidentally commited a merge conflict
commit c695494dbd6aaf252199da42ad763bdffa1d64b9
Merge: e5da62b 3322ca2
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Mon Jun 9 12:46:08 2025 +0200
Merge branch 'main' into motis
commit e5da62bcfc7953d5109ba53ae1fcc34f509f251b
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Wed Apr 30 18:15:39 2025 +0200
cpanfile: add Travel::Status::MOTIS dependency
commit 180723a9e0e2f0aede0bc6352d5eee601183ccef
Merge: 479373b c90ae4c
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Wed Apr 30 18:13:45 2025 +0200
Merge branch 'main' into motis
commit 479373b14eaadbc022199df246c9fb523a87188c
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Wed Apr 30 18:06:41 2025 +0200
database: remove duplicate users_with_backend migration
commit 94c8b5a7d1e2cb7f73b0eca7e33d916775504cd4
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Wed Apr 30 18:06:04 2025 +0200
Do not store train colours in database. They're only supported by MOTIS.
commit d58f23c3c7b06cc0243c1945dacd8673d2d2e428
Author: networkException <git@nwex.de>
Date: Fri Apr 18 11:47:02 2025 +0200
Initial MOTIS backend support
This patch adds support for checkins using MOTIS backends
using the Travel::Status::MOTIS module.
With this travelynx supports the two services currently
exposed by the module, RNV for local transit in Mannheim,
Germany and surrounding cities and transitous for worldwide
crowdsourced tranit feeds.
This implementation supports realtime predictions,
cancellations and polylines as well as custom route colors
if available.
As MOTIS doesn't expose names of indivial trips currently,
displaying transports is mostly limited to route names.
MOTIS uses strings for stop ids, based on the used GTFS
source feeds. As travelynx's data model currently assumes
interger station ids, this patch adds a mapping table
to the database.
This patch assumes support for MOTIS in db-fakedisplay.
Note that while träwelling has migrated to tranitous fully
sync remains unsupported for now.
See https://github.com/Traewelling/traewelling/issues/3345
Diffstat (limited to 'lib/Travelynx/Model/Journeys.pm')
-rwxr-xr-x | lib/Travelynx/Model/Journeys.pm | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm index f5bc9f1..fff59f9 100755 --- a/lib/Travelynx/Model/Journeys.pm +++ b/lib/Travelynx/Model/Journeys.pm @@ -549,7 +549,7 @@ sub get { my @select = ( - qw(journey_id is_dbris is_iris is_hafas backend_name backend_id train_type train_line train_no checkin_ts sched_dep_ts real_dep_ts dep_eva dep_ds100 dep_name dep_lat dep_lon checkout_ts sched_arr_ts real_arr_ts arr_eva arr_ds100 arr_name arr_lat arr_lon cancelled edited route messages user_data visibility effective_visibility) + qw(journey_id is_dbris is_iris is_hafas is_motis backend_name backend_id train_type train_line train_no checkin_ts sched_dep_ts real_dep_ts dep_eva dep_ds100 dep_name dep_lat dep_lon checkout_ts sched_arr_ts real_arr_ts arr_eva arr_ds100 arr_name arr_lat arr_lon cancelled edited route messages user_data visibility effective_visibility) ); my %where = ( user_id => $uid, @@ -610,6 +610,7 @@ sub get { is_dbris => $entry->{is_dbris}, is_iris => $entry->{is_iris}, is_hafas => $entry->{is_hafas}, + is_motis => $entry->{is_motis}, backend_name => $entry->{backend_name}, backend_id => $entry->{backend_id}, type => $entry->{train_type}, @@ -871,8 +872,9 @@ sub get_latest_checkout_stations { my $res = $db->select( 'journeys_str', [ - 'arr_name', 'arr_eva', 'train_id', 'backend_id', - 'backend_name', 'is_dbris', 'is_hafas' + 'arr_name', 'arr_eva', 'arr_external_id', 'train_id', + 'backend_id', 'backend_name', 'is_dbris', 'is_hafas', + 'is_motis' ], { user_id => $uid, @@ -894,11 +896,13 @@ sub get_latest_checkout_stations { push( @ret, { - name => $row->{arr_name}, - eva => $row->{arr_eva}, - dbris => $row->{is_dbris} ? $row->{backend_name} : 0, - hafas => $row->{is_hafas} ? $row->{backend_name} : 0, - backend_id => $row->{backend_id}, + name => $row->{arr_name}, + eva => $row->{arr_eva}, + external_id_or_eva => $row->{arr_external_id} // $row->{arr_eva}, + dbris => $row->{is_dbris} ? $row->{backend_name} : 0, + hafas => $row->{is_hafas} ? $row->{backend_name} : 0, + motis => $row->{is_motis} ? $row->{backend_name} : 0, + backend_id => $row->{backend_id}, } ); } @@ -1392,7 +1396,7 @@ sub compute_review { if ( not $most_undelay or $speedup > ( - $most_undelay->{sched_duration} + $most_undelay->{sched_duration} - $most_undelay->{rt_duration} ) ) @@ -1665,7 +1669,7 @@ sub compute_stats { @inconsistencies, { conflict => { - train => $journey->{type} . ' ' + train => ( $journey->{is_motis} ? '' : $journey->{type} ) . ' ' . ( $journey->{line} // $journey->{no} ), arr => epoch_to_dt( $journey->{rt_arr_ts} ) ->strftime('%d.%m.%Y %H:%M'), @@ -1691,7 +1695,7 @@ sub compute_stats { $next_departure = $journey->{rt_dep_ts}; $next_id = $journey->{id}; $next_train - = $journey->{type} . ' ' . ( $journey->{line} // $journey->{no} ),; + = ( $journey->{is_motis} ? '' : $journey->{type} ) . ' ' . ( $journey->{line} // $journey->{no} ),; } my $ret = { km_route => $km_route, @@ -1740,7 +1744,7 @@ sub get_stats { # checks out of a train or manually edits/adds a journey. if ( - not $opt{write_only} + not $opt{write_only} and not $opt{review} and my $stats = $self->stats_cache->get( uid => $uid, |