increase maximum comment length
This commit is contained in:
parent
b446b68e67
commit
cdce746afd
2 changed files with 72 additions and 72 deletions
|
@ -123,10 +123,10 @@ sub startup {
|
||||||
before_dispatch => sub {
|
before_dispatch => sub {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
# The "theme" cookie is set client-side if the theme we delivered was
|
# The "theme" cookie is set client-side if the theme we delivered was
|
||||||
# changed by dark mode detection or by using the theme switcher. It's
|
# changed by dark mode detection or by using the theme switcher. It's
|
||||||
# not part of Mojolicious' session data (and can't be, due to
|
# not part of Mojolicious' session data (and can't be, due to
|
||||||
# signing and HTTPOnly), so we need to add it here.
|
# signing and HTTPOnly), so we need to add it here.
|
||||||
for my $cookie ( @{ $self->req->cookies } ) {
|
for my $cookie ( @{ $self->req->cookies } ) {
|
||||||
if ( $cookie->name eq 'theme' ) {
|
if ( $cookie->name eq 'theme' ) {
|
||||||
$self->session( theme => $cookie->value );
|
$self->session( theme => $cookie->value );
|
||||||
|
@ -171,8 +171,8 @@ sub startup {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
# https://de.wikipedia.org/wiki/Liste_nach_Gemeinden_und_Regionen_benannter_IC/ICE-Fahrzeuge#Namensgebung_ICE-Triebz%C3%BCge_nach_Gemeinden
|
# https://de.wikipedia.org/wiki/Liste_nach_Gemeinden_und_Regionen_benannter_IC/ICE-Fahrzeuge#Namensgebung_ICE-Triebz%C3%BCge_nach_Gemeinden
|
||||||
# via https://github.com/marudor/bahn.expert/blob/main/src/server/coachSequence/TrainNames.ts
|
# via https://github.com/marudor/bahn.expert/blob/main/src/server/coachSequence/TrainNames.ts
|
||||||
$self->attr(
|
$self->attr(
|
||||||
ice_name => sub {
|
ice_name => sub {
|
||||||
my $id_to_name = JSON->new->utf8->decode(
|
my $id_to_name = JSON->new->utf8->decode(
|
||||||
|
@ -645,15 +645,15 @@ sub startup {
|
||||||
|
|
||||||
my $new_checkout_station_id = $status->{station_eva};
|
my $new_checkout_station_id = $status->{station_eva};
|
||||||
|
|
||||||
# When a checkout is triggered by a checkin, there is an edge case
|
# When a checkout is triggered by a checkin, there is an edge case
|
||||||
# with related stations.
|
# with related stations.
|
||||||
# Assume a user travels from A to B1, then from B2 to C. B1 and B2 are
|
# Assume a user travels from A to B1, then from B2 to C. B1 and B2 are
|
||||||
# relatd stations (e.g. "Frankfurt Hbf" and "Frankfurt Hbf(tief)").
|
# relatd stations (e.g. "Frankfurt Hbf" and "Frankfurt Hbf(tief)").
|
||||||
# Now, if they check in for the journey from B2 to C, and have not yet
|
# Now, if they check in for the journey from B2 to C, and have not yet
|
||||||
# checked out of the previous train, $train is undef as B2 is not B1.
|
# checked out of the previous train, $train is undef as B2 is not B1.
|
||||||
# Redo the request with with_related => 1 to avoid this case.
|
# Redo the request with with_related => 1 to avoid this case.
|
||||||
# While at it, we increase the lookahead to handle long journeys as
|
# While at it, we increase the lookahead to handle long journeys as
|
||||||
# well.
|
# well.
|
||||||
if ( not $train ) {
|
if ( not $train ) {
|
||||||
$status = $self->iris->get_departures(
|
$status = $self->iris->get_departures(
|
||||||
station => $station,
|
station => $station,
|
||||||
|
@ -692,9 +692,9 @@ sub startup {
|
||||||
|
|
||||||
if ( not defined $train ) {
|
if ( not defined $train ) {
|
||||||
|
|
||||||
# Arrival time via IRIS is unknown, so the train probably has not
|
# Arrival time via IRIS is unknown, so the train probably has not
|
||||||
# arrived yet. Fall back to HAFAS.
|
# arrived yet. Fall back to HAFAS.
|
||||||
# TODO support cases where $station is EVA or DS100 code
|
# TODO support cases where $station is EVA or DS100 code
|
||||||
if (
|
if (
|
||||||
my $station_data
|
my $station_data
|
||||||
= List::Util::first { $_->[0] eq $station }
|
= List::Util::first { $_->[0] eq $station }
|
||||||
|
@ -805,13 +805,13 @@ sub startup {
|
||||||
}
|
}
|
||||||
elsif ( defined $train and $train->arrival_is_cancelled ) {
|
elsif ( defined $train and $train->arrival_is_cancelled ) {
|
||||||
|
|
||||||
# This branch is only taken if the deparure was not cancelled,
|
# This branch is only taken if the deparure was not cancelled,
|
||||||
# i.e., if the train was supposed to go here but got
|
# i.e., if the train was supposed to go here but got
|
||||||
# redirected or cancelled on the way and not from the start on.
|
# redirected or cancelled on the way and not from the start on.
|
||||||
# If the departure itself was cancelled, the user route is
|
# If the departure itself was cancelled, the user route is
|
||||||
# cancelled_from action -> 'cancelled journey' panel on main page
|
# cancelled_from action -> 'cancelled journey' panel on main page
|
||||||
# -> cancelled_to action -> force checkout (causing the
|
# -> cancelled_to action -> force checkout (causing the
|
||||||
# previous branch to be taken due to $force)
|
# previous branch to be taken due to $force)
|
||||||
$journey->{cancelled} = 1;
|
$journey->{cancelled} = 1;
|
||||||
$self->journeys->add_from_in_transit(
|
$self->journeys->add_from_in_transit(
|
||||||
db => $db,
|
db => $db,
|
||||||
|
@ -946,8 +946,8 @@ sub startup {
|
||||||
|
|
||||||
my $db = $self->pg->db;
|
my $db = $self->pg->db;
|
||||||
|
|
||||||
# TODO "with_timestamps" is misleading, there are more differences between in_transit and in_transit_str
|
# TODO "with_timestamps" is misleading, there are more differences between in_transit and in_transit_str
|
||||||
# Here it's only needed because of dep_eva / arr_eva names
|
# Here it's only needed because of dep_eva / arr_eva names
|
||||||
my $in_transit = $self->in_transit->get(
|
my $in_transit = $self->in_transit->get(
|
||||||
db => $db,
|
db => $db,
|
||||||
uid => $uid,
|
uid => $uid,
|
||||||
|
@ -982,19 +982,19 @@ sub startup {
|
||||||
my $suggestion ( @{ $trainsearch->{suggestions} // [] } )
|
my $suggestion ( @{ $trainsearch->{suggestions} // [] } )
|
||||||
{
|
{
|
||||||
|
|
||||||
# Drunken API, sail with care. Both date formats are used interchangeably
|
# Drunken API, sail with care. Both date formats are used interchangeably
|
||||||
if (
|
if (
|
||||||
$suggestion->{depDate}
|
$suggestion->{depDate}
|
||||||
and ( $suggestion->{depDate} eq $date_yy
|
and ( $suggestion->{depDate} eq $date_yy
|
||||||
or $suggestion->{depDate} eq $date_yyyy )
|
or $suggestion->{depDate} eq $date_yyyy )
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
# Train numbers are not unique, e.g. IC 149 refers both to the
|
# Train numbers are not unique, e.g. IC 149 refers both to the
|
||||||
# InterCity service Amsterdam -> Berlin and to the InterCity service
|
# InterCity service Amsterdam -> Berlin and to the InterCity service
|
||||||
# Koebenhavns Lufthavn st -> Aarhus. One workaround is making
|
# Koebenhavns Lufthavn st -> Aarhus. One workaround is making
|
||||||
# requests with the stationFilter=80 parameter. Checking the origin
|
# requests with the stationFilter=80 parameter. Checking the origin
|
||||||
# station seems to be the more generic solution, so we do that
|
# station seems to be the more generic solution, so we do that
|
||||||
# instead.
|
# instead.
|
||||||
if ( $suggestion->{dep} eq $train->origin ) {
|
if ( $suggestion->{dep} eq $train->origin ) {
|
||||||
$result = $suggestion;
|
$result = $suggestion;
|
||||||
last;
|
last;
|
||||||
|
@ -1007,11 +1007,11 @@ sub startup {
|
||||||
return Mojo::Promise->reject("trainlink not found");
|
return Mojo::Promise->reject("trainlink not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
# Calculate and store trip_id.
|
# Calculate and store trip_id.
|
||||||
# The trip_id's date part doesn't seem to matter -- so far,
|
# The trip_id's date part doesn't seem to matter -- so far,
|
||||||
# HAFAS is happy as long as the date part starts with a number.
|
# HAFAS is happy as long as the date part starts with a number.
|
||||||
# HAFAS-internal tripIDs use this format (withouth leading zero
|
# HAFAS-internal tripIDs use this format (withouth leading zero
|
||||||
# for day of month < 10) though, so let's stick with it.
|
# for day of month < 10) though, so let's stick with it.
|
||||||
my $date_map = $date_yyyy;
|
my $date_map = $date_yyyy;
|
||||||
$date_map =~ tr{.}{}d;
|
$date_map =~ tr{.}{}d;
|
||||||
my $trip_id = sprintf( '1|%d|%d|%d|%s',
|
my $trip_id = sprintf( '1|%d|%d|%d|%s',
|
||||||
|
@ -1965,16 +1965,16 @@ sub startup {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Manual journey entries are only included if one of the following
|
# Manual journey entries are only included if one of the following
|
||||||
# conditions is satisfied:
|
# conditions is satisfied:
|
||||||
# * their route has more than two elements (-> probably more than just
|
# * their route has more than two elements (-> probably more than just
|
||||||
# start and stop station), or
|
# start and stop station), or
|
||||||
# * $include_manual is true (-> user wants to see incomplete routes)
|
# * $include_manual is true (-> user wants to see incomplete routes)
|
||||||
# This avoids messing up the map in case an A -> B connection has been
|
# This avoids messing up the map in case an A -> B connection has been
|
||||||
# tracked both with a regular checkin (-> detailed route shown on map)
|
# tracked both with a regular checkin (-> detailed route shown on map)
|
||||||
# and entered manually (-> beeline also shown on map, typically
|
# and entered manually (-> beeline also shown on map, typically
|
||||||
# significantly differs from detailed route) -- unless the user
|
# significantly differs from detailed route) -- unless the user
|
||||||
# sets include_manual, of course.
|
# sets include_manual, of course.
|
||||||
if ( $journey->{edited} & 0x0010
|
if ( $journey->{edited} & 0x0010
|
||||||
and @route <= 2
|
and @route <= 2
|
||||||
and not $include_manual )
|
and not $include_manual )
|
||||||
|
|
|
@ -123,21 +123,21 @@ sub get_connecting_trains_p {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
# In general, this function is meant to return feasible
|
# In general, this function is meant to return feasible
|
||||||
# connections. However, cancelled connections may also be of
|
# connections. However, cancelled connections may also be of
|
||||||
# interest and are also useful for logging cancellations.
|
# interest and are also useful for logging cancellations.
|
||||||
# To satisfy both demands with (hopefully) little confusion and
|
# To satisfy both demands with (hopefully) little confusion and
|
||||||
# UI clutter, this function returns two concatenated arrays:
|
# UI clutter, this function returns two concatenated arrays:
|
||||||
# actual connections (ordered by actual departure time) followed
|
# actual connections (ordered by actual departure time) followed
|
||||||
# by cancelled connections (ordered by scheduled departure time).
|
# by cancelled connections (ordered by scheduled departure time).
|
||||||
# This is easiest to achieve in two separate loops.
|
# This is easiest to achieve in two separate loops.
|
||||||
#
|
#
|
||||||
# Note that a cancelled train may still have a matching destination
|
# Note that a cancelled train may still have a matching destination
|
||||||
# in its route_post, e.g. if it leaves out $eva due to
|
# in its route_post, e.g. if it leaves out $eva due to
|
||||||
# unscheduled route changes but continues on schedule afterwards
|
# unscheduled route changes but continues on schedule afterwards
|
||||||
# -- so it is only cancelled at $eva, not on the remainder of
|
# -- so it is only cancelled at $eva, not on the remainder of
|
||||||
# the route. Also note that this specific case is not yet handled
|
# the route. Also note that this specific case is not yet handled
|
||||||
# properly by the cancellation logic etc.
|
# properly by the cancellation logic etc.
|
||||||
|
|
||||||
if ( $train->departure_is_cancelled ) {
|
if ( $train->departure_is_cancelled ) {
|
||||||
my @via = (
|
my @via = (
|
||||||
|
@ -158,7 +158,7 @@ sub get_connecting_trains_p {
|
||||||
{
|
{
|
||||||
push( @results, [ $train, $dest ] );
|
push( @results, [ $train, $dest ] );
|
||||||
|
|
||||||
# Show all past and up to two future departures per destination
|
# Show all past and up to two future departures per destination
|
||||||
if ( not $train->departure
|
if ( not $train->departure
|
||||||
or $train->departure->epoch >= $now )
|
or $train->departure->epoch >= $now )
|
||||||
{
|
{
|
||||||
|
@ -360,7 +360,7 @@ sub get_connecting_trains_p {
|
||||||
sub {
|
sub {
|
||||||
my ($err) = @_;
|
my ($err) = @_;
|
||||||
|
|
||||||
# TODO logging. HAFAS errors should never happen, IRIS errors are noteworthy too.
|
# TODO logging. HAFAS errors should never happen, IRIS errors are noteworthy too.
|
||||||
$promise->reject($err);
|
$promise->reject($err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -632,8 +632,8 @@ sub travel_action {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Silently ignore errors -- if they are permanent, the user will see
|
# Silently ignore errors -- if they are permanent, the user will see
|
||||||
# them when selecting the destination manually.
|
# them when selecting the destination manually.
|
||||||
my ( $still_checked_in, undef ) = $self->checkout(
|
my ( $still_checked_in, undef ) = $self->checkout(
|
||||||
station => $destination,
|
station => $destination,
|
||||||
force => 0
|
force => 0
|
||||||
|
@ -1035,10 +1035,10 @@ sub commute {
|
||||||
$candidate_count{ $journey->{from_name} }++;
|
$candidate_count{ $journey->{from_name} }++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Avoid selecting an intermediate station for multi-leg commutes.
|
# Avoid selecting an intermediate station for multi-leg commutes.
|
||||||
# Assumption: The intermediate station is also used for private
|
# Assumption: The intermediate station is also used for private
|
||||||
# travels -> penalize stations which are used on weekends or at
|
# travels -> penalize stations which are used on weekends or at
|
||||||
# unexpected times.
|
# unexpected times.
|
||||||
$candidate_count{ $journey->{from_name} }--;
|
$candidate_count{ $journey->{from_name} }--;
|
||||||
$candidate_count{ $journey->{to_name} }--;
|
$candidate_count{ $journey->{to_name} }--;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue