diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2022-07-09 19:39:01 +0200 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2022-07-09 19:39:01 +0200 | 
| commit | 40ff05aefe298c862bac9d474474fff0a475d0eb (patch) | |
| tree | d3718df735d281b1e02a772745f69d905985cd1c /lib/Travelynx | |
| parent | 7587cf42776bf9712f989b83ec7eff42c3d03901 (diff) | |
traewelling pull: skip API request for checked-in users
Diffstat (limited to 'lib/Travelynx')
| -rw-r--r-- | lib/Travelynx/Command/work.pm | 15 | 
1 files changed, 14 insertions, 1 deletions
| diff --git a/lib/Travelynx/Command/work.pm b/lib/Travelynx/Command/work.pm index b0458db..958f731 100644 --- a/lib/Travelynx/Command/work.pm +++ b/lib/Travelynx/Command/work.pm @@ -201,13 +201,26 @@ sub run {  	my $request_count = 0;  	for my $account_data ( $self->app->traewelling->get_pull_accounts ) { +		my $in_transit = $self->app->in_transit->get( +			uid => $account_data->{user_id}, +		); +		if ($in_transit) { +			$self->app->log->debug( +"Skipping Traewelling status pull for UID $account_data->{user_id}: already checked in" +			); +			next; +		} +  		# $account_data->{user_id} is the travelynx uid  		# $account_data->{user_name} is the Träwelling username  		$request_count += 1;  		$self->app->log->debug(  "Scheduling Traewelling status pull for UID $account_data->{user_id}"  		); -		Mojo::Promise->timer( $request_count * 0.2 )->then( + +		# In 'work', the event loop is not running, +		# so there's no need to multiply by $request_count at the moment +		Mojo::Promise->timer(0.5)->then(  			sub {  				return $self->app->traewelling_api->get_status_p(  					username => $account_data->{data}{user_name}, | 
