some optimization to reduce db selections

This commit is contained in:
ragu 2022-11-22 18:10:06 +01:00
parent f39ac77590
commit 8cfb680fec
9 changed files with 48 additions and 55 deletions

View file

@ -455,7 +455,9 @@ elsif($q->param('request') eq "bikes_available"){
$varenv{merchant_id} = $return_merchant->{merchant_id};
$response = { %$response, %$return_merchant };
my ($auth,$authraw) = $apif->auth_verify($q);
my $auth = {};
my $authraw = {};
($auth,$authraw) = $apif->auth_verify($q);
$response = { %$response, %$auth };
($response->{bikes},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$authraw,$return_merchant);
#$bw->log("X bikes_available $varenv{syshost} $stamp: $response->{user_group}",$response,"");
@ -464,16 +466,12 @@ elsif($q->param('request') eq "bikes_available"){
$varenv{merchant_id} = $return_merchant->{merchant_id};
#on operator loop select, operator adr must be select to get user_group
my ($auth,$authraw) = $apif->auth_verify($q);
my $auth = {};
my $authraw = {};
($auth,$authraw) = $apif->auth_verify($q,"","",1);
$response = { %$response, %$auth };
#$bw->log("Y bikes_available by c_id $authraw->{c_id}, Tarif:",$authraw->{txt30},"");
#sig first save
#if($varenv{syshost} eq "shareeapp-sx"){
# (my $response_bikes_disabled,my $return2copri->{bikes}) = $si->sig_available($q,\%varenv,$authraw);
# $tk->sigbike_cupdate($return2copri->{bikes});
#}
#$response->{bikes} = $apif->bikes_available($q,\%varenv,$authraw);
if($varenv{syshost} eq "shareeapp-sx"){
($response->{bikes},my $return2copri->{bikes}) = $si->sig_available($q,\%varenv,$authraw);
$tk->sigbike_cupdate($return2copri->{bikes});
@ -502,7 +500,9 @@ elsif($q->param('request') eq "bikes_all"){
($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id'));
$varenv{merchant_id} = $return_merchant->{merchant_id};
my ($auth,$authraw) = $apif->auth_verify($q);
my $auth = {};
my $authraw = {};
($auth,$authraw) = $apif->auth_verify($q,"","",1);
$response = { %$response, %$auth };
$response->{response_text} = "Vorsicht, das ist die Liste aller Leihräder unabhängig von der Verfügbarkeit";
@ -641,7 +641,9 @@ elsif($q->param('request') eq "stations_all"){
($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id'));
$varenv{merchant_id} = $return_merchant->{merchant_id};
my ($auth,$authraw) = $apif->auth_verify($q);
my $auth = {};
my $authraw = {};
($auth,$authraw) = $apif->auth_verify($q,"","",1);
$response = { %$response, %$auth };
my ($bikes_all,$bikes_allraw,$bikes_on_station) = $apif->bikes_all($q,\%varenv,$authraw,"");
($response->{stations},my $stations_allraw) = $apif->stations_all($q,\%varenv,$bikes_on_station,$authraw);
@ -667,15 +669,12 @@ elsif($q->param('request') eq "stations_available"){
($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id'));
$varenv{merchant_id} = $return_merchant->{merchant_id};
my ($auth,$authraw) = $apif->auth_verify($q);
my $auth = {};
my $authraw = {};
($auth,$authraw) = $apif->auth_verify($q,"","",1);
$response = { %$response, %$auth };
#sig first save
#if($varenv{syshost} eq "shareeapp-sx"){
# (my $response_stations_disabled,my $return2copri->{stations}) = $si->sig_available($q,\%varenv,$authraw);
# $tk->sigstation_cupdate($return2copri->{stations});
#}
#($response->{stations}, my $response_raw) = $apif->stations_available($q,\%varenv,$authraw,"");
if($varenv{syshost} eq "shareeapp-sx"){
($response->{stations},my $return2copri->{stations}) = $si->sig_available($q,\%varenv,$authraw);
$tk->sigstation_cupdate($return2copri->{stations});