summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-01-25 21:25:29 +0100
committerDaniel Friesel <derf@finalrewind.org>2022-01-25 21:25:29 +0100
commitb4f2978792b1abb8ec994aa96f993641d6bdfb53 (patch)
treec4f3ad255c647926ffac26e1e539b61262fe07ad /lib/DBInfoscreen.pm
parent2c75f4a4f7b29f7ef174b79c704678804701ac36 (diff)
refactor json_route_diff into Stationboard controller
Diffstat (limited to 'lib/DBInfoscreen.pm')
-rw-r--r--lib/DBInfoscreen.pm69
1 files changed, 2 insertions, 67 deletions
diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm
index ef3e0a0..afe139a 100644
--- a/lib/DBInfoscreen.pm
+++ b/lib/DBInfoscreen.pm
@@ -25,8 +25,8 @@ sub startup {
hafas_rest_api => $ENV{DBFAKEDISPLAY_HAFAS_API}
// 'https://v5.db.transport.rest',
hypnotoad => {
- accepts => $ENV{DBFAKEDISPLAY_ACCEPTS} // 100,
- clients => $ENV{DBFAKEDISPLAY_CLIENTS} // 10,
+ accepts => $ENV{DBFAKEDISPLAY_ACCEPTS} // 100,
+ clients => $ENV{DBFAKEDISPLAY_CLIENTS} // 10,
listen => [ $ENV{DBFAKEDISPLAY_LISTEN} // 'http://*:8092' ],
pid_file => $ENV{DBFAKEDISPLAY_PID_FILE}
// '/tmp/db-fakedisplay.pid',
@@ -214,71 +214,6 @@ sub startup {
);
$self->helper(
- 'json_route_diff' => sub {
- my ( $self, $route, $sched_route ) = @_;
- my @json_route;
- my @route = @{$route};
- my @sched_route = @{$sched_route};
-
- my $route_idx = 0;
- my $sched_idx = 0;
-
- while ( $route_idx <= $#route and $sched_idx <= $#sched_route ) {
- if ( $route[$route_idx] eq $sched_route[$sched_idx] ) {
- push( @json_route, { name => $route[$route_idx] } );
- $route_idx++;
- $sched_idx++;
- }
-
- # this branch is inefficient, but won't be taken frequently
- elsif ( not( $route[$route_idx] ~~ \@sched_route ) ) {
- push(
- @json_route,
- {
- name => $route[$route_idx],
- isAdditional => 1
- }
- );
- $route_idx++;
- }
- else {
- push(
- @json_route,
- {
- name => $sched_route[$sched_idx],
- isCancelled => 1
- }
- );
- $sched_idx++;
- }
- }
- while ( $route_idx <= $#route ) {
- push(
- @json_route,
- {
- name => $route[$route_idx],
- isAdditional => 1,
- isCancelled => 0
- }
- );
- $route_idx++;
- }
- while ( $sched_idx <= $#sched_route ) {
- push(
- @json_route,
- {
- name => $sched_route[$sched_idx],
- isAdditional => 0,
- isCancelled => 1
- }
- );
- $sched_idx++;
- }
- return @json_route;
- }
- );
-
- $self->helper(
'occupancy_icon' => sub {
my ( $self, $occupancy ) = @_;