diff options
| author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-06-15 08:23:48 +0200 | 
|---|---|---|
| committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-06-15 08:23:51 +0200 | 
| commit | c250a2f2c7968966014315f76b25109b83c041ed (patch) | |
| tree | 3c6ee328e7e67beadeac44d9458a048fe3e0b473 /lib/Travelynx/Command/work.pm | |
| parent | f1da50f9f18f0a2a5fd202daff4b6f0b517f35e0 (diff) | |
Add experimental EFA support
Squashed commit of the following:
commit b7457791ab7ab4859ebf4a5ce173e1aaeed4c7fb
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date:   Sun Jun 15 08:18:46 2025 +0200
    changelog
commit 7f3d61066195cfc3c83a8fc1b2fc3743e7e6171c
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date:   Sat Jun 14 19:55:51 2025 +0200
    Mark EFA backends as experimental for now
    For instance, VRR has very interesting issues when checking into departures
    that do not have real-time data yet.
commit 3370c0f6c25bd6b02cc4d56e9a3aba2a66d1151a
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date:   Sat Jun 14 19:49:48 2025 +0200
    InTransit: remove debug output
commit deb5444fa2965228b537e86fce862436ef2e6e19
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date:   Sat Jun 14 19:12:44 2025 +0200
    frontend js for checked-in view: never show fractional delays
commit d47ff9615b551bbd844a799be7717e9e74a04266
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date:   Sat Jun 14 19:12:31 2025 +0200
    worker: add EFA support
commit 3a955c0105bf13d040a821e2c87a19694202cde6
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date:   Sat Jun 14 17:48:46 2025 +0200
    EFA: checkin support
    worker support and cancellations are still missing
commit 19dea1ad13029d19cba38e7d1338718149c139fb
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date:   Sat Jun 14 14:32:59 2025 +0200
    actions.js: pass on efa parameter
commit 8f18ff2c8f9f906a387dbe16d372e1c4b4a6f259
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date:   Sat Jun 14 14:32:48 2025 +0200
    EFA: implement geolocation lookup
commit bce1139bab9aab167cdab910fa86085529d45b80
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date:   Sat Jun 14 14:32:21 2025 +0200
    EFA: ->id is no longer supported, use ->id_num
commit e4397e6b1538ddfa71da9839d6011a73fadc528f
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date:   Mon Jun 9 20:34:22 2025 +0200
    ... derp
commit e0c4cbf862a8f5a7bca0b1aceab3760af94093e9
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date:   Mon Jun 9 18:28:35 2025 +0200
    database: it's dbris, not ris
commit bfb1e834ce6c3171011dc20b32117065960b8771
Merge: 42f9a00 f1da50f
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date:   Mon Jun 9 18:20:51 2025 +0200
    Merge branch 'main' into efa-support
commit 42f9a00d98dbd675234c05b3e25c3e722cfdd7ba
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date:   Wed Jan 8 18:11:28 2025 +0100
    EFA support (WiP)
Diffstat (limited to 'lib/Travelynx/Command/work.pm')
| -rw-r--r-- | lib/Travelynx/Command/work.pm | 79 | 
1 files changed, 79 insertions, 0 deletions
| diff --git a/lib/Travelynx/Command/work.pm b/lib/Travelynx/Command/work.pm index 2b01cb2..5ea1810 100644 --- a/lib/Travelynx/Command/work.pm +++ b/lib/Travelynx/Command/work.pm @@ -185,6 +185,85 @@ sub run {  			next;  		} +		if ( $entry->{is_efa} ) { +			eval { +				$self->app->efa->get_journey_p( +					trip_id => $train_id, +					service => $entry->{backend_name} +				)->then( +					sub { +						my ($journey) = @_; + +						my $found_dep; +						my $found_arr; +						for my $stop ( $journey->route ) { +							if ( $stop->id_num == $dep ) { +								$found_dep = $stop; +							} +							if ( $arr and $stop->id_num == $arr ) { +								$found_arr = $stop; +								last; +							} +						} +						if ( not $found_dep ) { +							$self->app->log->debug( +								"Did not find $dep within journey $train_id"); +							return; +						} + +						if ( $found_dep->rt_dep ) { +							$self->app->in_transit->update_departure_efa( +								uid     => $uid, +								journey => $journey, +								stop    => $found_dep, +								dep_eva => $dep, +								arr_eva => $arr, +								trip_id => $train_id, +							); +						} + +						if ( $found_arr and $found_arr->rt_arr ) { +							$self->app->in_transit->update_arrival_efa( +								uid     => $uid, +								journey => $journey, +								stop    => $found_arr, +								dep_eva => $dep, +								arr_eva => $arr, +								trip_id => $train_id, +							); +						} +					} +				)->catch( +					sub { +						my ($err) = @_; +						$backend_issues += 1; +						$self->app->log->error( +"work($uid) @ EFA $entry->{backend_name}: journey: $err" +						); +					} +				)->wait; + +				if (    $arr +					and $entry->{real_arr_ts} +					and $now->epoch - $entry->{real_arr_ts} > 600 ) +				{ +					$self->app->checkout_p( +						station => $arr, +						force   => 2, +						dep_eva => $dep, +						arr_eva => $arr, +						uid     => $uid +					)->wait; +				} +			}; +			if ($@) { +				$errors += 1; +				$self->app->log->error( +					"work($uid) @ EFA $entry->{backend_name}: $@"); +			} +			next; +		} +  		if ( $entry->{is_motis} ) {  			eval { | 
