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_ENABLE=set_to_true_or_false
|
||||
HUB_FILTER_ENABLE=set_to_true_or_false
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ services:
|
|||
arguments:
|
||||
$country_code: "%env(COUNTRY_CODE)%"
|
||||
$cust_distance_limit: "%env(CUST_DISTANCE_LIMIT_ADMIN_PANEL)%"
|
||||
$hub_filter_enabled: "%env(HUB_FILTER_ENABLE)%"
|
||||
|
||||
#job order generator interface
|
||||
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\ResqJobOrderHandler"
|
||||
|
|
|
|||
|
|
@ -854,6 +854,8 @@ class APIController extends Controller implements LoggedController
|
|||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
// TODO: remove later
|
||||
// mobile app no longer calls this
|
||||
public function requestJobOrder(Request $req, InvoiceGeneratorInterface $ic, GeofenceTracker $geo,
|
||||
MapTools $map_tools, InventoryManager $im, MQTTClient $mclient,
|
||||
RiderAssignmentHandlerInterface $rah, PromoLogger $promo_logger,
|
||||
|
|
@ -2767,13 +2769,21 @@ class APIController extends Controller implements LoggedController
|
|||
$hub_criteria->setPoint($jo->getCoordinates());
|
||||
|
||||
// get distance limit for mobile from env
|
||||
// get value of hub_filter_enable from env
|
||||
$dotenv = new Dotenv();
|
||||
$dotenv->loadEnv(__DIR__.'/../../.env');
|
||||
$limit_distance = $_ENV['CUST_DISTANCE_LIMIT'];
|
||||
$hub_filter_enabled = $_ENV['HUB_FILTER_ENABLE'];
|
||||
|
||||
// set distance limit
|
||||
$hub_criteria->setLimitDistance($limit_distance);
|
||||
|
||||
// check if hub filter is enabled. If not, use default values
|
||||
// for the rest of the HubCriteria fields
|
||||
if ($hub_filter_enabled == 'true')
|
||||
{
|
||||
error_log('hub filter is enabled');
|
||||
// check if customer location is in hub filter area
|
||||
if ($hub_geofence->isCovered($long, $lat))
|
||||
{
|
||||
// if true, set other values for HubCriteria
|
||||
|
|
@ -2784,6 +2794,7 @@ class APIController extends Controller implements LoggedController
|
|||
->setPaymentMethod($jo->getModeOfPayment())
|
||||
->setRoundRobin(true);
|
||||
}
|
||||
}
|
||||
|
||||
// add battery to items
|
||||
$sku = $batt->getSAPCode();
|
||||
|
|
|
|||
|
|
@ -21,10 +21,6 @@ class HubFilteringGeoChecker
|
|||
|
||||
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
|
||||
if ($this->geofence_flag == 'true')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
protected $hub_dist;
|
||||
protected $hub_geofence;
|
||||
protected $cust_distance_limit;
|
||||
protected $hub_filter_enable;
|
||||
|
||||
protected $template_hash;
|
||||
|
||||
|
|
@ -89,7 +90,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
|
||||
string $country_code, WarrantyHandler $wh, RisingTideGateway $rt,
|
||||
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->ic = $ic;
|
||||
|
|
@ -104,6 +105,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$this->hub_dist = $hub_dist;
|
||||
$this->hub_geofence = $hub_geofence;
|
||||
$this->cust_distance_limit = $cust_distance_limit;
|
||||
$this->hub_filter_enabled = $hub_filter_enabled;
|
||||
|
||||
$this->loadTemplates();
|
||||
}
|
||||
|
|
@ -1986,6 +1988,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$hub_criteria->setPoint($obj->getCoordinates())
|
||||
->setLimitResults(50);
|
||||
|
||||
// check if hub filter is enabled. If not, use default values
|
||||
// for the rest of the HubCriteria fields
|
||||
if ($this->hub_filter_enabled == 'true')
|
||||
{
|
||||
error_log('hub filter is enabled');
|
||||
if ($this->hub_geofence->isCovered($long, $lat))
|
||||
{
|
||||
// if true, set other values for HubCriteria
|
||||
|
|
@ -1995,6 +2002,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
->setJoType($obj->getServiceType())
|
||||
->setRoundRobin(true);
|
||||
}
|
||||
}
|
||||
|
||||
// check if emergency or not
|
||||
$willing_to_wait = $obj->getWillWait();
|
||||
|
|
|
|||
Loading…
Reference in a new issue