mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 11:46:27 +01:00
sig feedback counter
This commit is contained in:
parent
25a86e87e5
commit
8bcc46416c
5 changed files with 98 additions and 65 deletions
|
@ -490,6 +490,24 @@ sub service_update(){
|
|||
my $return={};
|
||||
my $update = {};
|
||||
|
||||
my $bike = $q->escapeHTML($q->param('bike')) || "";
|
||||
my $bike_id = $bike;
|
||||
$bike_id =~ s/S[1-9]X/SX/;
|
||||
$bike_id = $1 if($bike_id =~ /(\d+)/);
|
||||
|
||||
my $pref = {
|
||||
table => "contenttrans",
|
||||
table_pos => "contenttranspos",
|
||||
fetch => "one",
|
||||
template_id => "218",#Mietjournal tpl_id
|
||||
barcode => $bike_id,
|
||||
ca_id => "$auth->{c_id}",
|
||||
"ct.close_time" => "is::null",
|
||||
int10 => "1",
|
||||
int28 => "3",
|
||||
};
|
||||
my $ctpos = { c_id => 0 };
|
||||
|
||||
if($q->param('request') eq "service_done"){
|
||||
$c_id = $q->param('service_id') if($q->param('service_id'));
|
||||
$update = {
|
||||
|
@ -507,6 +525,16 @@ sub service_update(){
|
|||
$update->{int01} = 1 if($q->param('bike_broken'));
|
||||
$update->{txt02} = $q->escapeHTML($q->param('message')) if($q->param('message'));
|
||||
|
||||
#to update sig int28 counter
|
||||
$ctpos = $dbt->collect_post($dbh,$pref) if($bike_id);
|
||||
if($ctpos->{c_id} > 0){
|
||||
my $update_pos = {
|
||||
table => "contenttranspos",
|
||||
mtime => "now()",
|
||||
int28 => "2",
|
||||
};
|
||||
$dbt->update_record($dbh,$update_pos,$ctpos);
|
||||
}
|
||||
}elsif($q->param('request') eq "user_minianswer"){
|
||||
$update = {
|
||||
table => "contentadrpos",
|
||||
|
@ -530,6 +558,29 @@ sub service_update(){
|
|||
$update->{int02} = $post_record->{int26} if($post_record->{int26});
|
||||
$update->{txt10} = $dbt->{operator}->{$last_used_operator}->{oprefix};
|
||||
}
|
||||
|
||||
#to update sig int28 counter
|
||||
$ctpos = $dbt->collect_post($dbh,$pref) if($bike_id);
|
||||
if($ctpos->{c_id} > 0){
|
||||
my $update_pos = {
|
||||
table => "contenttranspos",
|
||||
mtime => "now()",
|
||||
int28 => "null",
|
||||
};
|
||||
$dbt->update_record($dbh,$update_pos,$ctpos);
|
||||
|
||||
#user_miniquest_count
|
||||
my $user_miniquest_count = $auth->{int23} || 0;
|
||||
if($user_miniquest_count <= 3){
|
||||
$user_miniquest_count++;
|
||||
my $update_op = {
|
||||
table => "contentadr",
|
||||
int23 => $user_miniquest_count,
|
||||
atime => "now()",
|
||||
};
|
||||
my $rows = $dbt->update_record($dbh,$update_op,$auth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $record = { c_id => $c_id };
|
||||
|
@ -1510,6 +1561,29 @@ sub booking_update(){
|
|||
$booking_values->{lock_state} = "locking" if($booking->{int20} == 3);
|
||||
$booking_values->{lock_state} = "unlocking" if($booking->{int20} == 4);
|
||||
|
||||
#keep in mind, it works on operator dependency
|
||||
#only for project=Bayern and developer enabled
|
||||
#redundant code in APIfunc sub rentals for sig user_miniquery
|
||||
if($booking->{int10} == 1 && $dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern" && $auth->{int23} < 4){
|
||||
|
||||
$bw->log("user_miniquery via $varenv{dbname} user ID $auth->{c_id} exist count:",$auth->{int23},"");
|
||||
$booking_values->{user_miniquery} = $dbt->evaluationsfragen($dbh);
|
||||
|
||||
|
||||
#user_miniquest_count
|
||||
my $user_miniquest_count = $auth->{int23} || 0;
|
||||
if($user_miniquest_count <= 4){
|
||||
$user_miniquest_count++;
|
||||
my $update_op = {
|
||||
table => "contentadr",
|
||||
int23 => $user_miniquest_count,
|
||||
atime => "now()",
|
||||
};
|
||||
$rows = $dbt->update_record($dbh,$update_op,$auth);
|
||||
}
|
||||
}#end mini_quest
|
||||
|
||||
|
||||
#fetch tracking distance on Ilockit cloud by summary trip if(tracking && deviceId && available)
|
||||
if($booking->{int25} == 1 && $booking->{int10} == 1){
|
||||
$bw->log("get co2saving",$booking->{c_id},"");
|
||||
|
@ -1657,7 +1731,7 @@ sub user_bikes_occupied(){
|
|||
my $self = shift;
|
||||
my $q = shift;
|
||||
my $auth = shift;
|
||||
my $station_lock_state = shift || "";
|
||||
#my $station_lock_state = shift || "";
|
||||
|
||||
my $pref = {
|
||||
table => "contenttrans",
|
||||
|
@ -1674,7 +1748,7 @@ sub user_bikes_occupied(){
|
|||
#station_lock_stat enables a OR condition to view available as requested/occupied
|
||||
##selects also station_lock_state=locking bikes to view once miniquery
|
||||
#true if not defined! it will only defined on booking_request, because there must be available
|
||||
$pref->{station_lock_state} = "3" if(!$station_lock_state);
|
||||
#$pref->{station_lock_state} = "3" if(!$station_lock_state);
|
||||
my $record = $dbt->collect_post($dbh,$pref);
|
||||
return $record;
|
||||
}#end user_bikes_occupied
|
||||
|
@ -1716,44 +1790,20 @@ sub rentals(){
|
|||
}
|
||||
#sig update station_lock_state=locked to cancel once miniquery
|
||||
elsif($record->{$id}->{int11} && $record->{$id}->{int11} == 3){
|
||||
|
||||
#$return->{state} = "requested";#used once in App after sig rental-end push-notify
|
||||
$return->{$id}->{rentalId} = "$record->{$id}->{txt11}";
|
||||
|
||||
if($record->{$id}->{int28} && $record->{$id}->{int28} == 3){
|
||||
if($record->{$id}->{int28}){
|
||||
|
||||
$return->{$id}->{state} = "returned";
|
||||
#only for project=Bayern and developer enabled
|
||||
if($dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern" && $auth->{int23} < 4){
|
||||
|
||||
$bw->log("user_miniquery via $varenv{dbname} user ID $auth->{c_id} exist count:",$auth->{int23},"");
|
||||
$return->{$id}->{user_miniquery} = $dbt->evaluationsfragen($dbh);
|
||||
|
||||
#user_miniquest_count
|
||||
my $user_miniquest_count = $auth->{int23} || 0;
|
||||
if($user_miniquest_count <= 4){
|
||||
$user_miniquest_count++;
|
||||
my $update_op = {
|
||||
table => "contentadr",
|
||||
int23 => $user_miniquest_count,
|
||||
atime => "now()",
|
||||
};
|
||||
my $rows = $dbt->update_record($dbh,$update_op,$auth);
|
||||
}
|
||||
}#end mini_quest
|
||||
|
||||
$return->{$id}->{state} = "returned";#used once in App after sig rental-end push-notify
|
||||
$return->{$id}->{rentalId} = "$record->{$id}->{txt11}";
|
||||
|
||||
my $update_pos = {
|
||||
table => "contenttranspos",
|
||||
int28 => "1",
|
||||
c_id => "$id",
|
||||
};
|
||||
$dbt->update_record($dbh,$update_pos,$update_pos);
|
||||
$bw->log("sig update int28 station_lock_state=locked to cancel once miniquery",$update_pos,"");
|
||||
}
|
||||
}
|
||||
}
|
||||
}#end mini_quest
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}#end rentals
|
||||
|
|
|
@ -210,7 +210,8 @@ elsif($q->param('request') eq "booking_request"){
|
|||
|
||||
#check count of occcupied/requested bikes
|
||||
#"station_lock_state" disables a OR condition to view available as requested/occupied
|
||||
my $record = $apif->user_bikes_occupied($q,$authraw,"station_lock_state");
|
||||
#my $record = $apif->user_bikes_occupied($q,$authraw,"station_lock_state");
|
||||
my $record = $apif->user_bikes_occupied($q,$authraw);
|
||||
my $count=0;
|
||||
my $still_requested = 0;
|
||||
foreach my $id (keys(%$record)){
|
||||
|
@ -308,7 +309,8 @@ elsif($q->param('request') eq "booking_request"){
|
|||
|
||||
#return list of occupied/requested bikes
|
||||
#"station_lock_state" disables a OR condition to view available as requested/occupied
|
||||
$record = $apif->user_bikes_occupied($q,$authraw,"station_lock_state");
|
||||
#$record = $apif->user_bikes_occupied($q,$authraw,"station_lock_state");
|
||||
$record = $apif->user_bikes_occupied($q,$authraw);
|
||||
$response->{bikes_occupied} = $apif->rentals($record,$authraw,"1");#returns JSON rental values
|
||||
|
||||
}#end still_requested
|
||||
|
@ -393,29 +395,6 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki
|
|||
($rows, $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner,$sig_book);
|
||||
$response = {%$response, %$booking_values};
|
||||
}
|
||||
|
||||
#keep in mind, it works on operator dependency
|
||||
#only for project=Bayern and developer enabled
|
||||
#redundant code in APIfunc sub rentals for sig user_miniquery
|
||||
if($booking_values->{state} eq "available" && ($dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern" && $authraw->{int23} < 4)){
|
||||
|
||||
$bw->log("user_miniquery via $varenv{dbname} user ID $authraw->{c_id} exist count:",$authraw->{int23},"");
|
||||
$response->{user_miniquery} = $dbt->evaluationsfragen($dbh);
|
||||
|
||||
|
||||
#user_miniquest_count
|
||||
my $user_miniquest_count = $authraw->{int23} || 0;
|
||||
if($user_miniquest_count <= 4){
|
||||
$user_miniquest_count++;
|
||||
my $update_op = {
|
||||
table => "contentadr",
|
||||
int23 => $user_miniquest_count,
|
||||
atime => "now()",
|
||||
};
|
||||
my $rows = $dbt->update_record($dbh,$update_op,$authraw);
|
||||
}
|
||||
}#end mini_quest
|
||||
|
||||
}#end occupied|available
|
||||
|
||||
my $record = $apif->user_bikes_occupied($q,$authraw);
|
||||
|
@ -716,7 +695,7 @@ elsif($q->param('request') eq "user_feedback" || $q->param('request') eq "user_m
|
|||
|
||||
my $back_id = "";
|
||||
my $rows=0;
|
||||
#if(!$back_id){#disabled because of every feedback have to be saved
|
||||
#if(!$back_id)#disabled because of every feedback have to be saved
|
||||
if(1==1){
|
||||
#INSERT just dadaset
|
||||
$back_id = $apif->service_insert($q,$authraw,$node_template,$crecord,$aowner);
|
||||
|
|
|
@ -117,7 +117,7 @@ sub sig_booking_update {
|
|||
"event"=>"RENTAL_END",
|
||||
"data"=>{
|
||||
"bikeId"=>"test16b5-0522-43da-ab66-477744a731a3",
|
||||
"lockStatus"=>"unlocked",
|
||||
"lockStatus"=>"locked",
|
||||
"rentalId"=>"$rentalId",
|
||||
"reservationState"=>"",
|
||||
"startTime"=>"2022-06-06T15:00:18.045Z",
|
||||
|
@ -190,7 +190,7 @@ sub sig_booking_update {
|
|||
$q->param(-name=>'state',-value=>"available");
|
||||
$q->param(-name=>'lock_state',-value=>"locked");
|
||||
#addition state in context to get state=returned for miniquery
|
||||
$sig_book->{station_lock_state} = "3";
|
||||
$sig_book->{station_lock_state} = "3";#set int28 to 3
|
||||
}
|
||||
|
||||
($rows, $booking_values) = $apif->booking_update($q,$varenv,$authraw,$aowner,$sig_book) if($authraw->{c_id});
|
||||
|
|
|
@ -625,9 +625,13 @@ sub collect_post(){
|
|||
}elsif($key =~ /^(c_id|ca_id|ct_id|owner|barcode|int\d+)$/ && $value){
|
||||
$cp_where .= " and cp.$key $op $value";
|
||||
}
|
||||
}elsif($key eq "int10" && $value eq "('3','2')" && $fetch->{station_lock_state}){
|
||||
#selects also station_lock_state=locking bikes to view once miniquery
|
||||
$cp_where .= " and (cp.$key $op $value OR cp.int28 = 3)";
|
||||
#}elsif($key eq "int10" && $value eq "('3','2')" && $fetch->{station_lock_state}){
|
||||
#$cp_where .= " and (cp.$key $op $value OR cp.int28 = 3)";
|
||||
}elsif($key eq "int10" && $value eq "('3','2')"){
|
||||
#selects also push event=RENTAL_END station_lock_state bikes to view miniquery
|
||||
#that means in bikes_occupied context, that also rentals with int28>0
|
||||
#keep in mind: OR!!!-)
|
||||
$cp_where .= " and (cp.$key $op $value OR cp.int28 > 0)";
|
||||
}elsif($key =~ /^(c_id|ca_id|ct_id|owner|barcode|int\d+)$/ && $value){
|
||||
$cp_where .= " and cp.$key $op $value";
|
||||
}elsif($fetch->{catch} && $key eq "template_id" && $value){
|
||||
|
|
|
@ -45,8 +45,8 @@ sub tpl(){
|
|||
#my $api_test = "sharee_fr01"; my $bike="FR1538";
|
||||
#my $api_test = "sharee_fr01"; my $bike="FR4781";#Tracking and BVB test
|
||||
#my $api_test = "sharee_kn"; my $bike="KN205";
|
||||
#my $api_test = "sharee_wue"; my $bike="WUE5525";
|
||||
my $api_test = "sharee_sx"; my $bike="S3X1001";
|
||||
my $api_test = "sharee_wue"; my $bike="WUE5525";
|
||||
#my $api_test = "sharee_sx"; my $bike="S3X1001";
|
||||
#my $api_test = "sharee_ren"; my $bike="REN2";
|
||||
|
||||
print $q->div({-style=>'float:right;text-align:right;height:25px;padding:6px 15px;background-color:white'},$q->a({-style=>"background-color:#ffffff;color:#$bgcolor1;", -href=>"$varenv->{metahost}/src/scripts/tests/index.pl?sessionid=$coo\&api_test=$api_test\&bike=$bike", -target=>'_blank'}," [ tests --> $api_test ] "),"$users_sharee->{txt08}",$q->a({-style=>"color:#$bgcolor1;", -href=>"logout_sharee$session"},"logout")),"\n";
|
||||
|
|
Loading…
Add table
Reference in a new issue