From 625236667b297f4056201b49f8fe9162765f1338 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 15 Jul 2021 11:07:58 +0000 Subject: [PATCH 1/2] Add sorting by distance to round robin. #596 --- src/Service/HubDistributor.php | 10 ++++++++-- src/Service/JobOrderHandler/ResqJobOrderHandler.php | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Service/HubDistributor.php b/src/Service/HubDistributor.php index 2b32cce5..44069f03 100644 --- a/src/Service/HubDistributor.php +++ b/src/Service/HubDistributor.php @@ -95,14 +95,20 @@ class HubDistributor usort($arranged_hubs, function($a, $b) { if ($a['jo_count'] == $b['jo_count']) - return 0; + { + if ($a['distance'] == $b['distance']) + return 0; + if ($a['distance'] < $b['distance']) + return -1; + return 1; + } if ($a['jo_count'] < $b['jo_count']) return -1; else return 1; }); - //error_log('arranged hubs ' . json_encode($arranged_hubs)); + error_log('arranged hubs ' . json_encode($arranged_hubs)); return $arranged_hubs; } diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index 971f6903..092e9bf6 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -1985,7 +1985,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface if ($this->hub_geofence->isCovered($long, $lat)) { // 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->setPaymentMethod($obj->getModeOfPayment()) ->setJoType($obj->getServiceType()) ->setRoundRobin(true); From b761e2bfb5aea3cbcffb5aa12dabd9e7d4269ce1 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 16 Jul 2021 09:29:22 +0000 Subject: [PATCH 2/2] Add job order count for hubs in jo form. #596 --- src/Service/HubSelector.php | 2 +- .../JobOrderHandler/ResqJobOrderHandler.php | 2 + templates/job-order/form.html.twig | 118 +++++++++--------- 3 files changed, 62 insertions(+), 60 deletions(-) diff --git a/src/Service/HubSelector.php b/src/Service/HubSelector.php index ab810c20..87aea726 100644 --- a/src/Service/HubSelector.php +++ b/src/Service/HubSelector.php @@ -92,7 +92,7 @@ class HubSelector $hubs_round_robin = $this->filterHubsByRoundRobin($filtered_hubs, $flag_round_robin); $filtered_hubs = $hubs_round_robin; - //error_log('round robin hubs ' . json_encode($filtered_hubs)); + error_log('round robin hubs ' . json_encode($filtered_hubs)); // max results filter $hubs_max_result = $this->filterHubsByMaxResults($filtered_hubs, $limit_results, $jo_id, $customer_id); diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index 092e9bf6..32a2db28 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -2035,6 +2035,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // counters $hub['rider_count'] = count($hub['hub']->getAvailableRiders()); + $hub['redis_jo_count'] = $hub['jo_count']; $hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders()); // check for rejection @@ -2337,6 +2338,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // counters $hub['rider_count'] = count($hub['hub']->getAvailableRiders()); + $hub['redis_jo_count'] = $hub['jo_count']; $hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders()); // check for rejection diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index fede693a..e29d7aa5 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -645,67 +645,67 @@ {% if mode in ['update-processing', 'update-reassign-hub'] %} -
+
-
-

- Nearest Hubs -

-
-
-
- - -
- - - - - - - - - - - - - - - - - +
+

+ Nearest Hubs +

+
+
+
+ + +
+
HubBranchAvailable RidersJobs For AssignmentInventoryContact NumbersAction
- No items to display. -
+ + + + + + + + + + + + + + + + + - {% for hub in hubs %} - - - - - - - - - - - {% endfor %} - -
HubBranchAvailable RidersJob Order CountJobs For AssignmentInventoryContact NumbersAction
+ No items to display. +
{{ hub.hub.getName }}{{ hub.hub.getBranch }}{{ hub.rider_count }}{{ hub.jo_count }}{{ hub.inventory|default('0') }}{{ hub.hub.getContactNumbers|replace({"\n": ', '}) }} - {% if hub.flag_rejected %} - - {% else %} - - {% endif %} -
-
-
-
+ {% for hub in hubs %} + + {{ hub.hub.getName }} + {{ hub.hub.getBranch }} + + {{ hub.rider_count }} + {{ hub.redis_jo_count }} + {{ hub.jo_count }} + {{ hub.inventory|default('0') }} + {{ hub.hub.getContactNumbers|replace({"\n": ', '}) }} + + {% if hub.flag_rejected %} + + {% else %} + + {% endif %} + + + {% endfor %} + + +
+ +