diff --git a/.env.dist b/.env.dist index 1eaf2c17..611bfcfe 100644 --- a/.env.dist +++ b/.env.dist @@ -74,7 +74,7 @@ API_LOGGING=set_to_true_or_false CUST_DISTANCE_LIMIT=5 # customer distance limit in km for admin panel -ADMIN_PANEL_CUST_DISTANCE_LIMIT=5 +CUST_DISTANCE_LIMIT_ADMIN_PANEL=5 MAPTILER_API_KEY=map_tiler_api_key diff --git a/config/services.yaml b/config/services.yaml index fe949b8f..bed217dd 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -170,7 +170,7 @@ services: App\Service\JobOrderHandler\ResqJobOrderHandler: arguments: $country_code: "%env(COUNTRY_CODE)%" - $cust_distance_limit: "%env(ADMIN_PANEL_CUST_DISTANCE_LIMIT)%" + $cust_distance_limit: "%env(CUST_DISTANCE_LIMIT_ADMIN_PANEL)%" #job order generator interface App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\ResqJobOrderHandler" diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 31b720a6..cd0c8212 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -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 } } diff --git a/src/Service/HubDistributor.php b/src/Service/HubDistributor.php index 44069f03..8b296b7f 100644 --- a/src/Service/HubDistributor.php +++ b/src/Service/HubDistributor.php @@ -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; }