Merge branch '601-set-distance-limit-in-admin-panel' into 'master-fix'
Resolve "Set distance limit in admin panel" See merge request jankstudio/resq!719
This commit is contained in:
commit
9160cbe0af
6 changed files with 44 additions and 10 deletions
|
|
@ -70,8 +70,11 @@ INVENTORY_API_AUTH_TOKEN=insert_auth_token_here
|
|||
# API logging
|
||||
API_LOGGING=set_to_true_or_false
|
||||
|
||||
# customer distance limit in km
|
||||
CUST_DISTANCE_LIMIT=set_to_number
|
||||
# customer distance limit in km for mobile
|
||||
CUST_DISTANCE_LIMIT=5
|
||||
|
||||
# customer distance limit in km for admin panel
|
||||
CUST_DISTANCE_LIMIT_ADMIN_PANEL=5
|
||||
|
||||
MAPTILER_API_KEY=map_tiler_api_key
|
||||
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ services:
|
|||
App\Service\JobOrderHandler\ResqJobOrderHandler:
|
||||
arguments:
|
||||
$country_code: "%env(COUNTRY_CODE)%"
|
||||
$cust_distance_limit: "%env(CUST_DISTANCE_LIMIT_ADMIN_PANEL)%"
|
||||
|
||||
#job order generator interface
|
||||
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\ResqJobOrderHandler"
|
||||
|
|
|
|||
|
|
@ -1027,12 +1027,20 @@ class APIController extends Controller implements LoggedController
|
|||
$hub_criteria = new HubCriteria();
|
||||
$hub_criteria->setPoint($jo->getCoordinates());
|
||||
|
||||
// get distance limit for mobile from env
|
||||
$dotenv = new Dotenv();
|
||||
$dotenv->loadEnv(__DIR__.'/../../.env');
|
||||
$limit_distance = $_ENV['CUST_DISTANCE_LIMIT'];
|
||||
|
||||
// set distance limit
|
||||
$hub_criteria->setLimitDistance($limit_distance);
|
||||
|
||||
if ($hub_geofence->isCovered($long, $lat))
|
||||
{
|
||||
// TODO: set this properly, since the other flags
|
||||
// are on default values.
|
||||
// if true, set other values for HubCriteria
|
||||
// error_log('Area is covered by hub filtering');
|
||||
error_log('Area is covered by hub filtering');
|
||||
$hub_criteria->setJoType($jo->getServiceType())
|
||||
->setPaymentMethod($jo->getModeOfPayment())
|
||||
->setRoundRobin(true);
|
||||
|
|
@ -1096,7 +1104,7 @@ class APIController extends Controller implements LoggedController
|
|||
else
|
||||
{
|
||||
// log hub into hub_filter_log
|
||||
$hub_filter_logger->logFilteredHub($nearest_hub['hub'], 'no_available_rider');
|
||||
$hub_filter_logger->logFilteredHub($nearest_hub['hub'], 'no_available_rider', null, $cust->getID());
|
||||
// continue to go through list to find hub with an available rider
|
||||
}
|
||||
}
|
||||
|
|
@ -2758,12 +2766,20 @@ class APIController extends Controller implements LoggedController
|
|||
$hub_criteria = new HubCriteria();
|
||||
$hub_criteria->setPoint($jo->getCoordinates());
|
||||
|
||||
// get distance limit for mobile from env
|
||||
$dotenv = new Dotenv();
|
||||
$dotenv->loadEnv(__DIR__.'/../../.env');
|
||||
$limit_distance = $_ENV['CUST_DISTANCE_LIMIT'];
|
||||
|
||||
// set distance limit
|
||||
$hub_criteria->setLimitDistance($limit_distance);
|
||||
|
||||
if ($hub_geofence->isCovered($long, $lat))
|
||||
{
|
||||
// if true, set other values for HubCriteria
|
||||
// TODO: set this properly, since the other flags
|
||||
// are on default values
|
||||
// error_log('Area is covered by hub filtering');
|
||||
error_log('Area is covered by hub filtering');
|
||||
$hub_criteria->setJoType($jo->getServiceType())
|
||||
->setPaymentMethod($jo->getModeOfPayment())
|
||||
->setRoundRobin(true);
|
||||
|
|
@ -2827,7 +2843,7 @@ class APIController extends Controller implements LoggedController
|
|||
else
|
||||
{
|
||||
// log hub into hub_filter_log
|
||||
$hub_filter_logger->logFilteredHub($nearest_hub['hub'], 'no_available_rider');
|
||||
$hub_filter_logger->logFilteredHub($nearest_hub['hub'], 'no_available_rider', null, $cust->getID());
|
||||
// continue to go through list to find hub with an available rider
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class HubDistributor
|
|||
return 1;
|
||||
});
|
||||
|
||||
error_log('arranged hubs ' . json_encode($arranged_hubs));
|
||||
// error_log('arranged hubs ' . json_encode($arranged_hubs));
|
||||
|
||||
return $arranged_hubs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,10 @@ class HubSelector
|
|||
|
||||
$results = [];
|
||||
|
||||
error_log('payment methods ' . $payment_method);
|
||||
error_log('distance limit ' . $limit_distance);
|
||||
error_log('emergency flag ' . $flag_emergency);
|
||||
|
||||
// get all the hubs within distance
|
||||
$filtered_hubs = $this->getClosestHubs($point, $limit_distance, $jo_id, $customer_id);
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
protected $promo_logger;
|
||||
protected $hub_dist;
|
||||
protected $hub_geofence;
|
||||
protected $cust_distance_limit;
|
||||
|
||||
protected $template_hash;
|
||||
|
||||
|
|
@ -87,7 +88,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
|
||||
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
|
||||
string $country_code, WarrantyHandler $wh, RisingTideGateway $rt,
|
||||
PromoLogger $promo_logger, HubDistributor $hub_dist, HubFilteringGeoChecker $hub_geofence)
|
||||
PromoLogger $promo_logger, HubDistributor $hub_dist, HubFilteringGeoChecker $hub_geofence,
|
||||
string $cust_distance_limit)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->ic = $ic;
|
||||
|
|
@ -101,6 +103,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$this->promo_logger = $promo_logger;
|
||||
$this->hub_dist = $hub_dist;
|
||||
$this->hub_geofence = $hub_geofence;
|
||||
$this->cust_distance_limit = $cust_distance_limit;
|
||||
|
||||
$this->loadTemplates();
|
||||
}
|
||||
|
|
@ -1979,6 +1982,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$long = $obj->getCoordinates()->getLongitude();
|
||||
$lat = $obj->getCoordinates()->getLatitude();
|
||||
|
||||
// set result limit and location
|
||||
$hub_criteria->setPoint($obj->getCoordinates())
|
||||
->setLimitResults(50);
|
||||
|
||||
|
|
@ -1986,7 +1990,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
{
|
||||
// if true, set other values for HubCriteria
|
||||
error_log('Area is covered by hub filtering');
|
||||
$hub_criteria->setPaymentMethod($obj->getModeOfPayment())
|
||||
$hub_criteria->setLimitDistance($this->cust_distance_limit)
|
||||
->setPaymentMethod($obj->getModeOfPayment())
|
||||
->setJoType($obj->getServiceType())
|
||||
->setRoundRobin(true);
|
||||
}
|
||||
|
|
@ -1994,7 +1999,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
// check if emergency or not
|
||||
$willing_to_wait = $obj->getWillWait();
|
||||
if ($willing_to_wait == WillingToWaitContent::NOT_WILLING_TO_WAIT)
|
||||
{
|
||||
// reset distance limit if emergency
|
||||
$hub_criteria->setLimitDistance(500);
|
||||
$hub_criteria->setEmergency(true);
|
||||
}
|
||||
|
||||
// get JO and customer id for logging purposes
|
||||
$jo_id = $obj->getID();
|
||||
|
|
@ -2292,7 +2301,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
{
|
||||
// if true, set other values for HubCriteria
|
||||
// error_log('Area is covered by hub');
|
||||
$hub_criteria->setPaymentMethod($obj->getModeOfPayment())
|
||||
$hub_criteria->setLimitDistance($this->cust_distance_limit)
|
||||
->setPaymentMethod($obj->getModeOfPayment())
|
||||
->setJoType($obj->getServiceType())
|
||||
->setRoundRobin(true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue