summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen/Helper
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-03-27 13:27:15 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-03-27 13:27:15 +0100
commitaa9e55128f287b2e264df22997ec282b13f16fbe (patch)
treec7900bae91466f01fc280bf4f577460f8e281df9 /lib/DBInfoscreen/Helper
parent67c7349906ce6c9c93cc45f23046853f3ad07fbc (diff)
request EFA occupancy data (works for some VRR trains)
Diffstat (limited to 'lib/DBInfoscreen/Helper')
-rw-r--r--lib/DBInfoscreen/Helper/Marudor.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/DBInfoscreen/Helper/Marudor.pm b/lib/DBInfoscreen/Helper/Marudor.pm
index dad9dc7..dce22cf 100644
--- a/lib/DBInfoscreen/Helper/Marudor.pm
+++ b/lib/DBInfoscreen/Helper/Marudor.pm
@@ -80,6 +80,35 @@ sub get_json_p {
return $promise;
}
+sub get_efa_occupancy {
+ my ( $self, %opt ) = @_;
+
+ my $eva = $opt{eva};
+ my $train_no = $opt{train_no};
+ my $promise = Mojo::Promise->new;
+
+ $self->get_json_p( $self->{realtime_cache},
+ "https://vrrf.finalrewind.org/_eva/${eva}.json" )->then(
+ sub {
+ my ($utilization_json) = @_;
+
+ if ( $utilization_json->{$train_no}{occupancy} ) {
+ $promise->resolve( $utilization_json->{$train_no}{occupancy} );
+ return;
+ }
+ $promise->reject;
+ return;
+ }
+ )->catch(
+ sub {
+ $promise->reject;
+ return;
+ }
+ )->wait;
+
+ return $promise;
+}
+
sub get_train_utilization {
my ( $self, %opt ) = @_;