Add hub filter option in .env. #605
This commit is contained in:
parent
ac0edd5467
commit
0de8f71d0e
5 changed files with 37 additions and 20 deletions
|
|
@ -89,3 +89,4 @@ HUB_JO_KEY=hub_jo_count
|
||||||
|
|
||||||
# hub geofence
|
# hub geofence
|
||||||
HUB_GEOFENCE_ENABLE=set_to_true_or_false
|
HUB_GEOFENCE_ENABLE=set_to_true_or_false
|
||||||
|
HUB_FILTER_ENABLE=set_to_true_or_false
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
$country_code: "%env(COUNTRY_CODE)%"
|
$country_code: "%env(COUNTRY_CODE)%"
|
||||||
$cust_distance_limit: "%env(CUST_DISTANCE_LIMIT_ADMIN_PANEL)%"
|
$cust_distance_limit: "%env(CUST_DISTANCE_LIMIT_ADMIN_PANEL)%"
|
||||||
|
$hub_filter_enabled: "%env(HUB_FILTER_ENABLE)%"
|
||||||
|
|
||||||
#job order generator interface
|
#job order generator interface
|
||||||
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\ResqJobOrderHandler"
|
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\ResqJobOrderHandler"
|
||||||
|
|
|
||||||
|
|
@ -854,6 +854,8 @@ class APIController extends Controller implements LoggedController
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove later
|
||||||
|
// mobile app no longer calls this
|
||||||
public function requestJobOrder(Request $req, InvoiceGeneratorInterface $ic, GeofenceTracker $geo,
|
public function requestJobOrder(Request $req, InvoiceGeneratorInterface $ic, GeofenceTracker $geo,
|
||||||
MapTools $map_tools, InventoryManager $im, MQTTClient $mclient,
|
MapTools $map_tools, InventoryManager $im, MQTTClient $mclient,
|
||||||
RiderAssignmentHandlerInterface $rah, PromoLogger $promo_logger,
|
RiderAssignmentHandlerInterface $rah, PromoLogger $promo_logger,
|
||||||
|
|
@ -2767,22 +2769,31 @@ class APIController extends Controller implements LoggedController
|
||||||
$hub_criteria->setPoint($jo->getCoordinates());
|
$hub_criteria->setPoint($jo->getCoordinates());
|
||||||
|
|
||||||
// get distance limit for mobile from env
|
// get distance limit for mobile from env
|
||||||
|
// get value of hub_filter_enable from env
|
||||||
$dotenv = new Dotenv();
|
$dotenv = new Dotenv();
|
||||||
$dotenv->loadEnv(__DIR__.'/../../.env');
|
$dotenv->loadEnv(__DIR__.'/../../.env');
|
||||||
$limit_distance = $_ENV['CUST_DISTANCE_LIMIT'];
|
$limit_distance = $_ENV['CUST_DISTANCE_LIMIT'];
|
||||||
|
$hub_filter_enabled = $_ENV['HUB_FILTER_ENABLE'];
|
||||||
|
|
||||||
// set distance limit
|
// set distance limit
|
||||||
$hub_criteria->setLimitDistance($limit_distance);
|
$hub_criteria->setLimitDistance($limit_distance);
|
||||||
|
|
||||||
if ($hub_geofence->isCovered($long, $lat))
|
// check if hub filter is enabled. If not, use default values
|
||||||
|
// for the rest of the HubCriteria fields
|
||||||
|
if ($hub_filter_enabled == 'true')
|
||||||
{
|
{
|
||||||
// if true, set other values for HubCriteria
|
error_log('hub filter is enabled');
|
||||||
// TODO: set this properly, since the other flags
|
// check if customer location is in hub filter area
|
||||||
// are on default values
|
if ($hub_geofence->isCovered($long, $lat))
|
||||||
error_log('Area is covered by hub filtering');
|
{
|
||||||
$hub_criteria->setJoType($jo->getServiceType())
|
// if true, set other values for HubCriteria
|
||||||
->setPaymentMethod($jo->getModeOfPayment())
|
// TODO: set this properly, since the other flags
|
||||||
->setRoundRobin(true);
|
// are on default values
|
||||||
|
error_log('Area is covered by hub filtering');
|
||||||
|
$hub_criteria->setJoType($jo->getServiceType())
|
||||||
|
->setPaymentMethod($jo->getModeOfPayment())
|
||||||
|
->setRoundRobin(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add battery to items
|
// add battery to items
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,6 @@ class HubFilteringGeoChecker
|
||||||
|
|
||||||
public function isCovered($long, $lat)
|
public function isCovered($long, $lat)
|
||||||
{
|
{
|
||||||
// TODO: remove this
|
|
||||||
// NOTE: this is a temporary fix to disable hub filtering altogether
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// check if geofence is enabled
|
// check if geofence is enabled
|
||||||
if ($this->geofence_flag == 'true')
|
if ($this->geofence_flag == 'true')
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
protected $hub_dist;
|
protected $hub_dist;
|
||||||
protected $hub_geofence;
|
protected $hub_geofence;
|
||||||
protected $cust_distance_limit;
|
protected $cust_distance_limit;
|
||||||
|
protected $hub_filter_enable;
|
||||||
|
|
||||||
protected $template_hash;
|
protected $template_hash;
|
||||||
|
|
||||||
|
|
@ -89,7 +90,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
|
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
|
||||||
string $country_code, WarrantyHandler $wh, RisingTideGateway $rt,
|
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)
|
string $cust_distance_limit, string $hub_filter_enabled)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->ic = $ic;
|
$this->ic = $ic;
|
||||||
|
|
@ -104,6 +105,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$this->hub_dist = $hub_dist;
|
$this->hub_dist = $hub_dist;
|
||||||
$this->hub_geofence = $hub_geofence;
|
$this->hub_geofence = $hub_geofence;
|
||||||
$this->cust_distance_limit = $cust_distance_limit;
|
$this->cust_distance_limit = $cust_distance_limit;
|
||||||
|
$this->hub_filter_enabled = $hub_filter_enabled;
|
||||||
|
|
||||||
$this->loadTemplates();
|
$this->loadTemplates();
|
||||||
}
|
}
|
||||||
|
|
@ -1986,14 +1988,20 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$hub_criteria->setPoint($obj->getCoordinates())
|
$hub_criteria->setPoint($obj->getCoordinates())
|
||||||
->setLimitResults(50);
|
->setLimitResults(50);
|
||||||
|
|
||||||
if ($this->hub_geofence->isCovered($long, $lat))
|
// check if hub filter is enabled. If not, use default values
|
||||||
|
// for the rest of the HubCriteria fields
|
||||||
|
if ($this->hub_filter_enabled == 'true')
|
||||||
{
|
{
|
||||||
// if true, set other values for HubCriteria
|
error_log('hub filter is enabled');
|
||||||
error_log('Area is covered by hub filtering');
|
if ($this->hub_geofence->isCovered($long, $lat))
|
||||||
$hub_criteria->setLimitDistance($this->cust_distance_limit)
|
{
|
||||||
->setPaymentMethod($obj->getModeOfPayment())
|
// if true, set other values for HubCriteria
|
||||||
->setJoType($obj->getServiceType())
|
error_log('Area is covered by hub filtering');
|
||||||
->setRoundRobin(true);
|
$hub_criteria->setLimitDistance($this->cust_distance_limit)
|
||||||
|
->setPaymentMethod($obj->getModeOfPayment())
|
||||||
|
->setJoType($obj->getServiceType())
|
||||||
|
->setRoundRobin(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if emergency or not
|
// check if emergency or not
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue