summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2025-12-27 19:06:50 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2025-12-27 19:06:50 +0100
commit3bdfdc74045b48937c446d96fc581931f544fc64 (patch)
treece57dcba910e665e864f89f6c20cb6a44dd1393e
parente9e06417cff8f42beb4debc9a90cb439f53e0bce (diff)
checkin suggestions: respect "use_history" account configuration
-rw-r--r--lib/Travelynx/Command/work.pm11
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm109
2 files changed, 71 insertions, 49 deletions
diff --git a/lib/Travelynx/Command/work.pm b/lib/Travelynx/Command/work.pm
index 35c90c2..d6e70ed 100644
--- a/lib/Travelynx/Command/work.pm
+++ b/lib/Travelynx/Command/work.pm
@@ -53,6 +53,9 @@ sub run {
my $arr = $entry->{arr_eva};
my $train_id = $entry->{train_id};
+ my $use_history = $self->app->users->use_history( uid => $uid );
+ my $suggestions_enabled = $use_history & 0x02;
+
if ( $train_id eq 'manual' ) {
if ( $arr
and $entry->{real_arr_ts}
@@ -201,7 +204,9 @@ sub run {
uid => $uid
)->wait;
}
- elsif ( $entry->{real_arr_ts} - $now->epoch < 900 ) {
+ elsif ( $suggestions_enabled
+ and $entry->{real_arr_ts} - $now->epoch < 900 )
+ {
my @destinations
= $self->app->journeys->get_connection_targets(
uid => $uid,
@@ -332,7 +337,9 @@ sub run {
uid => $uid
)->wait;
}
- elsif ( $entry->{real_arr_ts} - $now->epoch < 900 ) {
+ elsif ( $suggestions_enabled
+ and $entry->{real_arr_ts} - $now->epoch < 900 )
+ {
my @destinations
= $self->app->journeys->get_connection_targets(
uid => $uid,
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index f328ba8..148701f 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -784,6 +784,8 @@ sub station {
}
my @suggestions;
+ my $use_history = $self->users->use_history( uid => $uid );
+ my $suggestions_enabled = $use_history & 0x01;
my $promise;
if ($dbris_service) {
@@ -878,21 +880,27 @@ sub station {
sort { $b->[1] <=> $a->[1] }
map { [ $_, $_->dep->epoch ] } $status->results;
- my ($eva) = ( $station =~ m{ [@] L = (\d+) }x );
- my $backend_id
- = $self->stations->get_backend_id( dbris => $dbris_service );
- my @destinations = $self->journeys->get_connection_targets(
- uid => $uid,
- backend_id => $backend_id,
- eva => $eva
- );
- @suggestions = $self->dbris->grep_suggestions(
- status => $status,
- destinations => \@destinations
- );
+ if ($suggestions_enabled) {
+ my ($eva) = ( $station =~ m{ [@] L = (\d+) }x );
+ my $backend_id
+ = $self->stations->get_backend_id(
+ dbris => $dbris_service );
+
+ my @destinations = $self->journeys->get_connection_targets(
+ uid => $uid,
+ backend_id => $backend_id,
+ eva => $eva
+ );
+
+ @suggestions = $self->dbris->grep_suggestions(
+ status => $status,
+ destinations => \@destinations
+ );
- @suggestions = sort { $a->[0]{sort_ts} <=> $b->[0]{sort_ts} }
- grep { $_->[0]{sort_ts} >= $now - 300 } @suggestions;
+ @suggestions
+ = sort { $a->[0]{sort_ts} <=> $b->[0]{sort_ts} }
+ grep { $_->[0]{sort_ts} >= $now - 300 } @suggestions;
+ }
$status = {
station_eva => $station,
@@ -928,22 +936,29 @@ sub station {
@results = map { $_->[0] }
sort { $b->[1] <=> $a->[1] }
map { [ $_, $_->datetime->epoch ] } $status->results;
- my $backend_id
- = $self->stations->get_backend_id( efa => $efa_service );
- my @destinations = $self->journeys->get_connection_targets(
- uid => $uid,
- backend_id => $backend_id,
- eva => $status->stop->id_num,
- );
- @suggestions = $self->efa->grep_suggestions(
- status => $status,
- destinations => \@destinations
- );
- @suggestions = sort { $a->[0]{sort_ts} <=> $b->[0]{sort_ts} }
- grep {
- $_->[0]{sort_ts} >= $now - 300
- and $_->[0]{sort_ts} <= $now + 1800
- } @suggestions;
+
+ if ($suggestions_enabled) {
+ my $backend_id
+ = $self->stations->get_backend_id( efa => $efa_service );
+
+ my @destinations = $self->journeys->get_connection_targets(
+ uid => $uid,
+ backend_id => $backend_id,
+ eva => $status->stop->id_num,
+ );
+
+ @suggestions = $self->efa->grep_suggestions(
+ status => $status,
+ destinations => \@destinations
+ );
+
+ @suggestions
+ = sort { $a->[0]{sort_ts} <=> $b->[0]{sort_ts} }
+ grep {
+ $_->[0]{sort_ts} >= $now - 300
+ and $_->[0]{sort_ts} <= $now + 1800
+ } @suggestions;
+ }
$status = {
station_eva => $status->stop->id_num,
@@ -975,27 +990,27 @@ sub station {
[ $_, $_->departure->epoch // $_->sched_departure->epoch ]
} @results;
- my @destinations = $self->journeys->get_connection_targets(
- uid => $uid,
- backend_id => 0,
- eva => $status->{station_eva},
- );
-
- for my $dep (@results) {
- destination: for my $dest (@destinations) {
- for my $via_name ( $dep->route_post ) {
- if ( $via_name eq $dest->{name} ) {
- push( @suggestions, [ $dep, $dest ] );
- next destination;
+ if ($suggestions_enabled) {
+ my @destinations = $self->journeys->get_connection_targets(
+ uid => $uid,
+ backend_id => 0,
+ eva => $status->{station_eva},
+ );
+ for my $dep (@results) {
+ destination: for my $dest (@destinations) {
+ for my $via_name ( $dep->route_post ) {
+ if ( $via_name eq $dest->{name} ) {
+ push( @suggestions, [ $dep, $dest ] );
+ next destination;
+ }
}
}
}
+ @suggestions = map { $_->[0] }
+ sort { $a->[1] <=> $b->[1] }
+ grep { $_->[1] >= $now - 300 }
+ map { [ $_, $_->[0]->departure->epoch ] } @suggestions;
}
-
- @suggestions = map { $_->[0] }
- sort { $a->[1] <=> $b->[1] }
- grep { $_->[1] >= $now - 300 }
- map { [ $_, $_->[0]->departure->epoch ] } @suggestions;
}
my $user_status = $self->get_user_status;