summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-03-03 09:58:06 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2024-03-03 09:58:06 +0100
commit09531c474d341f4232e291a253ec3c7e2210070c (patch)
tree5727388b4798894444367ceb2417371f382efe96
parent7d1bf77228a649590870673865cbce1cae076eef (diff)
Wagonorder: remove unused dbdb cache and station info functions4.20.8
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm2
-rw-r--r--lib/DBInfoscreen/Helper/Wagonorder.pm159
2 files changed, 1 insertions, 160 deletions
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index 06ce041..c4b3d08 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -711,7 +711,7 @@ sub render_train {
= ( $wagonorder_req, $occupancy_req, $stationinfo_req, $route_req );
if ( $departure->{wr_link} ) {
- $self->wagonorder->is_available_p( $result, $departure->{wr_link} )
+ $self->wagonorder->get_p( $result->train_no, $departure->{wr_link} )
->then(
sub {
# great!
diff --git a/lib/DBInfoscreen/Helper/Wagonorder.pm b/lib/DBInfoscreen/Helper/Wagonorder.pm
index d59df14..5cdee40 100644
--- a/lib/DBInfoscreen/Helper/Wagonorder.pm
+++ b/lib/DBInfoscreen/Helper/Wagonorder.pm
@@ -24,165 +24,6 @@ sub new {
}
-sub is_available_p {
- my ( $self, $train, $wr_link ) = @_;
- my $promise = Mojo::Promise->new;
-
- $self->check_wagonorder_p( $train->train_no, $wr_link )->then(
- sub {
- my ($body) = @_;
- $promise->resolve($body);
- return;
- },
- sub {
- if ( $train->is_wing ) {
- my $wing = $train->wing_of;
- return $self->check_wagonorder_p( $wing->train_no, $wr_link );
- }
- else {
- $promise->reject;
- return;
- }
- }
- )->then(
- sub {
- my ($body) = @_;
- $promise->resolve($body);
- return;
- },
- sub {
- $promise->reject;
- return;
- }
- )->wait;
-
- return $promise;
-}
-
-sub get_dbdb_p {
- my ( $self, $url ) = @_;
-
- my $promise = Mojo::Promise->new;
-
- my $cache = $self->{main_cache};
-
- if ( my $content = $cache->get($url) ) {
- if ($content) {
- return $promise->resolve($content);
- }
- else {
- return $promise->reject;
- }
- }
-
- $self->{user_agent}->request_timeout(5)->get_p( $url => $self->{header} )
- ->then(
- sub {
- my ($tx) = @_;
- if ( $tx->result->is_success ) {
- my $body = $tx->result->body;
- $cache->set( $url, $body );
- $promise->resolve($body);
- }
- else {
- $cache->set( $url, q{} );
- $promise->reject;
- }
- return;
- }
- )->catch(
- sub {
- $cache->set( $url, q{} );
- $promise->reject;
- return;
- }
- )->wait;
- return $promise;
-}
-
-sub head_dbdb_p {
- my ( $self, $url ) = @_;
-
- my $promise = Mojo::Promise->new;
-
- my $cache = $self->{main_cache};
-
- if ( my $content = $cache->get($url) ) {
- $self->{log}->debug("wagonorder->head_dbdb_p($url): cached ($content)");
- if ( $content eq 'y' ) {
- return $promise->resolve;
- }
- else {
- return $promise->reject;
- }
- }
-
- $self->{user_agent}->request_timeout(5)->head_p( $url => $self->{header} )
- ->then(
- sub {
- my ($tx) = @_;
- if ( $tx->result->is_success ) {
- $self->{log}->debug("wagonorder->head_dbdb_p($url): y");
- $cache->set( $url, 'y' );
- $promise->resolve;
- }
- else {
- $self->{log}->debug("wagonorder->head_dbdb_p($url): n");
- $cache->set( $url, 'n' );
- $promise->reject;
- }
- return;
- }
- )->catch(
- sub {
- $self->{log}->debug("wagonorder->head_dbdb_p($url): n");
- $cache->set( $url, 'n' );
- $promise->reject;
- return;
- }
- )->wait;
- return $promise;
-}
-
-sub has_cycle_p {
- my ( $self, $train_no ) = @_;
-
- return $self->head_dbdb_p(
- "https://lib.finalrewind.org/dbdb/db_umlauf/${train_no}.svg");
-}
-
-sub check_wagonorder_p {
- my ( $self, $train_no, $wr_link ) = @_;
-
- my $promise = Mojo::Promise->new;
-
- $self->head_dbdb_p(
- "https://lib.finalrewind.org/dbdb/has_wagonorder/${train_no}/${wr_link}"
- )->then(
- sub {
- $promise->resolve;
- return;
- }
- )->catch(
- sub {
- $self->get_p( $train_no, $wr_link )->then(
- sub {
- $promise->resolve;
- return;
- }
- )->catch(
- sub {
- $promise->reject;
- return;
- }
- )->wait;
- return;
- }
- )->wait;
-
- return $promise;
-}
-
sub get_p {
my ( $self, $train_no, $api_ts ) = @_;