Merge branch '596-add-distance-when-sorting-for-round-robin-hub-filtering' into 'master-fix'

Resolve "Add distance when sorting for round robin hub filtering"

See merge request jankstudio/resq!714
This commit is contained in:
Kendrick Chan 2021-07-21 05:35:28 +00:00
commit a2fa95ac98
4 changed files with 71 additions and 63 deletions

View file

@ -95,14 +95,20 @@ class HubDistributor
usort($arranged_hubs, function($a, $b) { usort($arranged_hubs, function($a, $b) {
if ($a['jo_count'] == $b['jo_count']) if ($a['jo_count'] == $b['jo_count'])
{
if ($a['distance'] == $b['distance'])
return 0; return 0;
if ($a['distance'] < $b['distance'])
return -1;
return 1;
}
if ($a['jo_count'] < $b['jo_count']) if ($a['jo_count'] < $b['jo_count'])
return -1; return -1;
else else
return 1; return 1;
}); });
//error_log('arranged hubs ' . json_encode($arranged_hubs)); error_log('arranged hubs ' . json_encode($arranged_hubs));
return $arranged_hubs; return $arranged_hubs;
} }

View file

@ -92,7 +92,7 @@ class HubSelector
$hubs_round_robin = $this->filterHubsByRoundRobin($filtered_hubs, $flag_round_robin); $hubs_round_robin = $this->filterHubsByRoundRobin($filtered_hubs, $flag_round_robin);
$filtered_hubs = $hubs_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 // max results filter
$hubs_max_result = $this->filterHubsByMaxResults($filtered_hubs, $limit_results, $jo_id, $customer_id); $hubs_max_result = $this->filterHubsByMaxResults($filtered_hubs, $limit_results, $jo_id, $customer_id);

View file

@ -1985,7 +1985,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
if ($this->hub_geofence->isCovered($long, $lat)) if ($this->hub_geofence->isCovered($long, $lat))
{ {
// if true, set other values for HubCriteria // 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()) $hub_criteria->setPaymentMethod($obj->getModeOfPayment())
->setJoType($obj->getServiceType()) ->setJoType($obj->getServiceType())
->setRoundRobin(true); ->setRoundRobin(true);
@ -2035,6 +2035,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// counters // counters
$hub['rider_count'] = count($hub['hub']->getAvailableRiders()); $hub['rider_count'] = count($hub['hub']->getAvailableRiders());
$hub['redis_jo_count'] = $hub['jo_count'];
$hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders()); $hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders());
// check for rejection // check for rejection
@ -2337,6 +2338,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// counters // counters
$hub['rider_count'] = count($hub['hub']->getAvailableRiders()); $hub['rider_count'] = count($hub['hub']->getAvailableRiders());
$hub['redis_jo_count'] = $hub['jo_count'];
$hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders()); $hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders());
// check for rejection // check for rejection

View file

@ -662,11 +662,11 @@
<tr> <tr>
<th>Hub</th> <th>Hub</th>
<th>Branch</th> <th>Branch</th>
<!-- <!--<th class="text-right">Distance</th>
<th class="text-right">Distance</th>
<th class="text-right">Travel Time</th> <th class="text-right">Travel Time</th>
--> -->
<th class="text-right">Available Riders</th> <th class="text-right">Available Riders</th>
<th class="text-right">Job Order Count</th>
<th class="text-right">Jobs For Assignment</th> <th class="text-right">Jobs For Assignment</th>
<th class="text-right">Inventory</th> <th class="text-right">Inventory</th>
<th>Contact Numbers</th> <th>Contact Numbers</th>
@ -675,7 +675,7 @@
</thead> </thead>
<tbody> <tbody>
<tr class="placeholder-row{{ hubs|length > 0 ? ' hide' }}"> <tr class="placeholder-row{{ hubs|length > 0 ? ' hide' }}">
<td colspan="7"> <td colspan="8">
No items to display. No items to display.
</td> </td>
</tr> </tr>
@ -684,11 +684,11 @@
<tr data-lat="{{ hub.hub.getCoordinates.getLatitude }}" data-lng="{{ hub.hub.getCoordinates.getLongitude }}" data-id="{{ hub.hub.getID }}"{{ obj.getHub and obj.getHub.getID == hub.hub.getID ? ' class="m-table__row--primary"' }}> <tr data-lat="{{ hub.hub.getCoordinates.getLatitude }}" data-lng="{{ hub.hub.getCoordinates.getLongitude }}" data-id="{{ hub.hub.getID }}"{{ obj.getHub and obj.getHub.getID == hub.hub.getID ? ' class="m-table__row--primary"' }}>
<td>{{ hub.hub.getName }}</td> <td>{{ hub.hub.getName }}</td>
<td>{{ hub.hub.getBranch }}</td> <td>{{ hub.hub.getBranch }}</td>
<!-- <!--<td class="text-right">{{ hub.distance ? hub.distance : '-' }}</td>
<td class="text-right">{{ hub.distance ? hub.distance : '-' }}</td>
<td class="text-right">{{ hub.duration ? hub.duration : '-' }}</td> <td class="text-right">{{ hub.duration ? hub.duration : '-' }}</td>
--> -->
<td class="text-right">{{ hub.rider_count }}</td> <td class="text-right">{{ hub.rider_count }}</td>
<td class="text-right">{{ hub.redis_jo_count }}</td>
<td class="text-right">{{ hub.jo_count }}</td> <td class="text-right">{{ hub.jo_count }}</td>
<td class="text-right">{{ hub.inventory|default('0') }}</td> <td class="text-right">{{ hub.inventory|default('0') }}</td>
<td>{{ hub.hub.getContactNumbers|replace({"\n": ', '}) }}</td> <td>{{ hub.hub.getContactNumbers|replace({"\n": ', '}) }}</td>