summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-10-30 17:14:21 +0100
committerDaniel Friesel <derf@finalrewind.org>2022-10-30 17:14:21 +0100
commit4dbbedaf6bd953e5d57023eefc3acf742e91f511 (patch)
tree17161670d4758b096840ee77c77b1378ce595d1d /lib
parent6b5d0f8bcc7ea7c76093803cbf8d52d8a0b0a377 (diff)
Move EFA code to separate helper class
Diffstat (limited to 'lib')
-rw-r--r--lib/DBInfoscreen.pm10
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm2
-rw-r--r--lib/DBInfoscreen/Helper/EFA.pm (renamed from lib/DBInfoscreen/Helper/Marudor.pm)12
-rw-r--r--lib/DBInfoscreen/Helper/HAFAS.pm2
4 files changed, 13 insertions, 13 deletions
diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm
index 23823f1..83cb77a 100644
--- a/lib/DBInfoscreen.pm
+++ b/lib/DBInfoscreen.pm
@@ -7,8 +7,8 @@ package DBInfoscreen;
use Mojo::Base 'Mojolicious';
use Cache::File;
+use DBInfoscreen::Helper::EFA;
use DBInfoscreen::Helper::HAFAS;
-use DBInfoscreen::Helper::Marudor;
use DBInfoscreen::Helper::Wagonorder;
use File::Slurp qw(read_file);
use JSON;
@@ -125,9 +125,9 @@ sub startup {
);
$self->helper(
- hafas => sub {
+ efa => sub {
my ($self) = @_;
- state $hafas = DBInfoscreen::Helper::HAFAS->new(
+ state $efa = DBInfoscreen::Helper::EFA->new(
log => $self->app->log,
main_cache => $self->app->cache_iris_main,
realtime_cache => $self->app->cache_iris_rt,
@@ -139,9 +139,9 @@ sub startup {
);
$self->helper(
- marudor => sub {
+ hafas => sub {
my ($self) = @_;
- state $hafas = DBInfoscreen::Helper::Marudor->new(
+ state $hafas = DBInfoscreen::Helper::HAFAS->new(
log => $self->app->log,
main_cache => $self->app->cache_iris_main,
realtime_cache => $self->app->cache_iris_rt,
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index 5a8c44e..735cbe7 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -597,7 +597,7 @@ sub render_train {
$wagonorder_req->resolve;
}
- $self->marudor->get_efa_occupancy(
+ $self->efa->get_efa_occupancy(
eva => $result->station_uic,
train_no => $result->train_no
)->then(
diff --git a/lib/DBInfoscreen/Helper/Marudor.pm b/lib/DBInfoscreen/Helper/EFA.pm
index 352829b..2386ebb 100644
--- a/lib/DBInfoscreen/Helper/Marudor.pm
+++ b/lib/DBInfoscreen/Helper/EFA.pm
@@ -1,6 +1,6 @@
-package DBInfoscreen::Helper::Marudor;
+package DBInfoscreen::Helper::EFA;
-# Copyright (C) 2020 Daniel Friesel
+# Copyright (C) 2020-2022 Daniel Friesel
#
# SPDX-License-Identifier: AGPL-3.0-or-later
@@ -35,7 +35,7 @@ sub get_json_p {
my $promise = Mojo::Promise->new;
if ( my $content = $cache->thaw($url) ) {
- $self->{log}->debug("marudor->get_json_p($url): cached");
+ $self->{log}->debug("efa->get_json_p($url): cached");
if ( $content->{error} ) {
return $promise->reject( $content->{error} );
}
@@ -49,7 +49,7 @@ sub get_json_p {
if ( my $err = $tx->error ) {
$self->{log}->debug(
-"marudor->get_json_p($url): HTTP $err->{code} $err->{message}"
+"efa->get_json_p($url): HTTP $err->{code} $err->{message}"
);
$cache->freeze( $url, { error => $err->{message} } );
$promise->reject(
@@ -61,7 +61,7 @@ sub get_json_p {
if ( not $res ) {
$self->{log}
- ->debug("marudor->get_json_p($url): empty response");
+ ->debug("efa->get_json_p($url): empty response");
$promise->reject("GET $url returned empty response");
return;
}
@@ -75,7 +75,7 @@ sub get_json_p {
)->catch(
sub {
my ($err) = @_;
- $self->{log}->debug("marudor->get_json_p($url): $err");
+ $self->{log}->debug("efa->get_json_p($url): $err");
$cache->freeze( $url, { error => $err } );
$promise->reject($err);
return;
diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm
index 2fb088a..28f5f02 100644
--- a/lib/DBInfoscreen/Helper/HAFAS.pm
+++ b/lib/DBInfoscreen/Helper/HAFAS.pm
@@ -1,6 +1,6 @@
package DBInfoscreen::Helper::HAFAS;
-# Copyright (C) 2011-2020 Daniel Friesel
+# Copyright (C) 2011-2022 Daniel Friesel
#
# SPDX-License-Identifier: AGPL-3.0-or-later