Traewelling::get: Use named args

This commit is contained in:
Daniel Friesel 2022-02-16 20:39:49 +01:00
parent 8f906da9c2
commit ef3252863e
No known key found for this signature in database
GPG key ID: 100D5BFB5166E005
3 changed files with 9 additions and 7 deletions

View file

@ -30,7 +30,7 @@ sub settings {
password => $password password => $password
)->then( )->then(
sub { sub {
my $traewelling = $self->traewelling->get($uid); my $traewelling = $self->traewelling->get( uid => $uid );
$self->param( sync_source => 'none' ); $self->param( sync_source => 'none' );
$self->render( $self->render(
'traewelling', 'traewelling',
@ -53,7 +53,7 @@ sub settings {
} }
elsif ( $self->param('action') and $self->param('action') eq 'logout' ) { elsif ( $self->param('action') and $self->param('action') eq 'logout' ) {
$self->render_later; $self->render_later;
my $traewelling = $self->traewelling->get($uid); my $traewelling = $self->traewelling->get( uid => $uid );
$self->traewelling_api->logout_p( $self->traewelling_api->logout_p(
uid => $uid, uid => $uid,
token => $traewelling->{token} token => $traewelling->{token}
@ -88,7 +88,7 @@ sub settings {
return; return;
} }
my $traewelling = $self->traewelling->get($uid); my $traewelling = $self->traewelling->get( uid => $uid );
if ( $traewelling->{push_sync} ) { if ( $traewelling->{push_sync} ) {
$self->param( sync_source => 'travelynx' ); $self->param( sync_source => 'travelynx' );

View file

@ -94,11 +94,13 @@ sub unlink {
} }
sub get { sub get {
my ( $self, $uid ) = @_; my ( $self, %opt ) = @_;
$uid //= $self->current_user->{id};
my $uid = $opt{uid};
my $db = $opt{db} // $self->{pg}->db;
my $res_h my $res_h
= $self->{pg}->db->select( 'traewelling_str', '*', { user_id => $uid } ) = $db->select( 'traewelling_str', '*', { user_id => $uid } )
->expand->hash; ->expand->hash;
$res_h->{latest_run} = epoch_to_dt( $res_h->{latest_run_ts} ); $res_h->{latest_run} = epoch_to_dt( $res_h->{latest_run_ts} );

View file

@ -36,7 +36,7 @@
% my $acc = current_user(); % my $acc = current_user();
% my $hook = get_webhook(); % my $hook = get_webhook();
% my $traewelling = traewelling->get($acc->{id}); % my $traewelling = traewelling->get(uid => $acc->{id});
% my $use_history = users->use_history(uid => $acc->{id}); % my $use_history = users->use_history(uid => $acc->{id});
<div class="row"> <div class="row">
<div class="col s12"> <div class="col s12">