mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 19:56:29 +01:00
station caching fix
This commit is contained in:
parent
2a3f579b94
commit
a638aad485
3 changed files with 33 additions and 30 deletions
|
@ -2176,21 +2176,7 @@ sub stations_available(){
|
|||
else{
|
||||
$pref_sql .= " and (";
|
||||
foreach my $main_id (@{$bike_node}){
|
||||
#on rental end select only stations which are defined
|
||||
#A-A rental
|
||||
if($station_bike_node && $main_id =~ /(\d+)/ && $aa_station){
|
||||
my $node_id = $1;
|
||||
if($node_id == $station_bike_node){
|
||||
$pref_sql .= " ct.int04 = $aa_station OR";
|
||||
}
|
||||
#A-B rental
|
||||
}elsif($station_bike_node && $main_id =~ /(\d+)/){
|
||||
my $node_id = $1;
|
||||
if($node_id == $station_bike_node){
|
||||
$pref_sql .= " ct.txt24 like '%$node_id%' OR";
|
||||
}
|
||||
#without a rental
|
||||
}elsif($main_id =~ /(\d+)/){
|
||||
if($main_id =~ /(\d+)/){
|
||||
my $node_id = $1;
|
||||
$pref_sql .= " ct.txt24 like '%$node_id%' OR";
|
||||
}
|
||||
|
@ -2268,20 +2254,25 @@ sub stations_available(){
|
|||
$return->{$id}->{operator_data}->{operator_phone} = $hotline_data->{txt07} if($hotline_data->{txt07});
|
||||
$return->{$id}->{operator_data}->{operator_email} = $hotline_data->{txt08} if($hotline_data->{txt08});
|
||||
|
||||
$return->{$id}->{cached} = "0";
|
||||
$return->{$id}->{cached} = "0";
|
||||
$return->{$id}->{withpub} = "0";
|
||||
if($dbt->{operator}->{$varenv->{dbname}}->{cache_station} == 1 && $cachme){
|
||||
$return->{$id}->{cached} = "1";
|
||||
foreach my $tarif_key (keys(%$adrtarif_hash)){
|
||||
$return->{$id}->{withpub}= "1" if($adrtarif_hash->{$tarif_key} == 2);
|
||||
}
|
||||
}
|
||||
|
||||
$op_return->{$dbt->{operator}->{$varenv->{dbname}}->{oprefix} . $id} = $return->{$id};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#json caching
|
||||
if($dbt->{operator}->{$varenv->{dbname}}->{cache_station} == 1 && $cachme){
|
||||
$return->{$id}->{withpub} = "0";
|
||||
|
||||
#order by sharing_type
|
||||
foreach my $tarif_key (keys(%$adrtarif_hash)){
|
||||
$return->{$id}->{withpub}= "1" if($adrtarif_hash->{$tarif_key} == 2 || $adrtarif_hash->{$tarif_key} == 5);
|
||||
$return->{$id}->{cached} = "$cachme";
|
||||
$op_return->{$dbt->{operator}->{$varenv->{dbname}}->{oprefix} . $id} = $return->{$id};
|
||||
#my $stationsout = $json->pretty->encode({ shareejson => { stations => $op_return } });
|
||||
my $stationsout = $json->pretty->encode($op_return);
|
||||
|
||||
if($cachme){
|
||||
|
@ -2302,8 +2293,6 @@ sub stations_available(){
|
|||
}
|
||||
}
|
||||
}#end caching
|
||||
}
|
||||
}
|
||||
|
||||
return ($op_return, $record);
|
||||
}#end stations_available
|
||||
|
@ -2500,8 +2489,14 @@ sub fetch_tariff(){
|
|||
elsif(looks_like_number($cachme) && $cachme > 0){
|
||||
$tariff->{barcode} = $cachme;
|
||||
$tariff_all = $dbt->fetch_record($dbh,$tariff);
|
||||
$auth_operator = { txt30 => "$cachme" };
|
||||
$bw->log("$dbname $cachme Tariff type for No operator registered user by barcode:$tariff->{barcode} select 2:",$tariff_all,"");
|
||||
if($tariff_all->{$cachme}->{int18} == 2 || $tariff_all->{$cachme}->{int18} == 5){
|
||||
delete $tariff->{barcode};
|
||||
$tariff->{int18} = 2;
|
||||
$tariff_all = $dbt->fetch_record($dbh,$tariff);
|
||||
}else{
|
||||
$auth_operator = { txt30 => "$cachme" };
|
||||
}
|
||||
$bw->log("$dbname $cachme Tariff type for No operator registered user by barcode:$tariff->{barcode} OR int18: $tariff->{int18} select 2:",$tariff_all,"");
|
||||
}
|
||||
#if no primary address then only 2=public
|
||||
elsif((ref($adr) ne "HASH" || !$adr->{c_id}) && ($dbname ne "sharee_lv")){
|
||||
|
|
|
@ -145,7 +145,7 @@ var icon_red = L.icon({
|
|||
});
|
||||
|
||||
//stations and bikes at all
|
||||
if(1==2){
|
||||
if('$dbt->{operator}->{$varenv->{dbname}}->{merchant_id}'){
|
||||
Promise.all([
|
||||
fetch(
|
||||
"$uri_request/GBFSout?request=stations_available&authcookie=$api_return->{authcookie}"
|
||||
|
@ -204,9 +204,11 @@ Promise.all([
|
|||
|
||||
map.fitBounds(layerGroup.getBounds());
|
||||
});
|
||||
}//end stations and bikes at all
|
||||
}
|
||||
|
||||
//Only stations with bike_count
|
||||
else{
|
||||
|
||||
Promise.all([
|
||||
fetch(
|
||||
"$uri_request/GBFSout?request=stations_available&authcookie=$api_return->{authcookie}"
|
||||
|
@ -249,7 +251,7 @@ Promise.all([
|
|||
|
||||
map.fitBounds(layerGroup.getBounds());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
EOF
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
initMap="47.976634, 7.825490"
|
||||
map_zoom="13"
|
||||
cache_station=0
|
||||
withpub=0
|
||||
<database>
|
||||
dbname=sharee_operator
|
||||
host=localhost
|
||||
|
@ -93,6 +94,7 @@
|
|||
initMap="47.976634, 7.825490"
|
||||
map_zoom="13"
|
||||
cache_station=0
|
||||
withpub=0
|
||||
<database>
|
||||
dbname=sharee_operator
|
||||
host=localhost
|
||||
|
@ -128,6 +130,7 @@
|
|||
<queexee3Da>
|
||||
id = 298
|
||||
name = "example Pr"
|
||||
app_name=""
|
||||
project="all"
|
||||
user_agent = ""
|
||||
initMap = "47.976634, 7.825490"
|
||||
|
@ -141,6 +144,7 @@
|
|||
<ong5ohc6Oi>
|
||||
id = 296
|
||||
name = "example Op"
|
||||
app_name=""
|
||||
project="Example"
|
||||
user_agent = ""
|
||||
initMap = "47.976634, 7.825490"
|
||||
|
@ -154,6 +158,7 @@
|
|||
<eiFiPaing9>
|
||||
id = 294
|
||||
name = "example Web"
|
||||
app_name=""
|
||||
project="Example"
|
||||
user_agent = ""
|
||||
initMap = "47.976634, 7.825490"
|
||||
|
@ -167,6 +172,7 @@
|
|||
<exzooLu4oh>
|
||||
id = 295
|
||||
name = "example App"
|
||||
app_name="sharee.bike"
|
||||
project="Example"
|
||||
user_agent = ""
|
||||
initMap = "47.976634, 7.825490"
|
||||
|
@ -188,8 +194,8 @@
|
|||
logdir = "/var/log/copri4"
|
||||
basedir = "/var/www/copri4"
|
||||
<type_id>
|
||||
300101 = "Lastenräder"
|
||||
300103 = "Stadträder"
|
||||
300101 = "Lastenrad"
|
||||
300103 = "Stadtrad"
|
||||
</type_id>
|
||||
<sharing_type>
|
||||
2 = "public"
|
||||
|
|
Loading…
Add table
Reference in a new issue