summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Command/work.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-10-01 19:36:35 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-10-01 19:36:35 +0200
commit07e0f8970681422a48fec9da5d14ad2a2b3735bd (patch)
tree9fa0a9e5492eae9f048bd607935c2906859ad9b9 /lib/Travelynx/Command/work.pm
parent590d3de51891705730eca92527f0d4f651570a29 (diff)
allow checking into traewelling
Diffstat (limited to 'lib/Travelynx/Command/work.pm')
-rw-r--r--lib/Travelynx/Command/work.pm20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Travelynx/Command/work.pm b/lib/Travelynx/Command/work.pm
index 593735f..5a79b10 100644
--- a/lib/Travelynx/Command/work.pm
+++ b/lib/Travelynx/Command/work.pm
@@ -259,6 +259,26 @@ sub run {
)->wait;
}
+ for my $candidate ( $self->app->traewelling->get_pushable_accounts ) {
+ $self->app->log->debug(
+ "Pushing to Traewelling for UID $candidate->{uid}");
+ my $trip_id = $candidate->{journey_data}{trip_id};
+ if ( not $trip_id ) {
+ $self->app->log->debug("... trip_id is missing");
+
+ # TODO log traewelling error
+ return;
+ }
+ if ( $candidate->{data}{latest_push_ts}
+ and $candidate->{data}{latest_push_ts} == $candidate->{checkin_ts} )
+ {
+ $self->app->log->debug("... already handled");
+ return;
+ }
+ $self->app->traewelling_api->checkin( %{$candidate},
+ trip_id => $trip_id );
+ }
+
# Computing yearly stats may take a while, but we've got all time in the
# world here. This means users won't have to wait when loading their
# own by-year journey log.