From ef3252863e28905fe96a49a91e5a62c156c69e6e Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 16 Feb 2022 20:39:49 +0100 Subject: Traewelling::get: Use named args --- lib/Travelynx/Controller/Traewelling.pm | 6 +++--- lib/Travelynx/Model/Traewelling.pm | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/Travelynx/Controller/Traewelling.pm b/lib/Travelynx/Controller/Traewelling.pm index e906b1f..d3e6d6c 100644 --- a/lib/Travelynx/Controller/Traewelling.pm +++ b/lib/Travelynx/Controller/Traewelling.pm @@ -30,7 +30,7 @@ sub settings { password => $password )->then( sub { - my $traewelling = $self->traewelling->get($uid); + my $traewelling = $self->traewelling->get( uid => $uid ); $self->param( sync_source => 'none' ); $self->render( 'traewelling', @@ -53,7 +53,7 @@ sub settings { } elsif ( $self->param('action') and $self->param('action') eq 'logout' ) { $self->render_later; - my $traewelling = $self->traewelling->get($uid); + my $traewelling = $self->traewelling->get( uid => $uid ); $self->traewelling_api->logout_p( uid => $uid, token => $traewelling->{token} @@ -88,7 +88,7 @@ sub settings { return; } - my $traewelling = $self->traewelling->get($uid); + my $traewelling = $self->traewelling->get( uid => $uid ); if ( $traewelling->{push_sync} ) { $self->param( sync_source => 'travelynx' ); diff --git a/lib/Travelynx/Model/Traewelling.pm b/lib/Travelynx/Model/Traewelling.pm index a334c1d..e05ff7d 100644 --- a/lib/Travelynx/Model/Traewelling.pm +++ b/lib/Travelynx/Model/Traewelling.pm @@ -94,11 +94,13 @@ sub unlink { } sub get { - my ( $self, $uid ) = @_; - $uid //= $self->current_user->{id}; + my ( $self, %opt ) = @_; + + my $uid = $opt{uid}; + my $db = $opt{db} // $self->{pg}->db; my $res_h - = $self->{pg}->db->select( 'traewelling_str', '*', { user_id => $uid } ) + = $db->select( 'traewelling_str', '*', { user_id => $uid } ) ->expand->hash; $res_h->{latest_run} = epoch_to_dt( $res_h->{latest_run_ts} ); -- cgit v1.2.3