Add logging for filtered hubs. #543
This commit is contained in:
parent
2db7c6791f
commit
4966e7e0c6
4 changed files with 61 additions and 10 deletions
|
|
@ -272,9 +272,15 @@ services:
|
|||
$em: "@doctrine.orm.entity_manager"
|
||||
$im: "@App\\Service\\InventoryManager"
|
||||
$hub_distributor: "@App\\Service\\HubDistributor"
|
||||
$hub_filter_logger: "@App\\Service\\HubFilterLogger"
|
||||
|
||||
# hub distributor
|
||||
App\Service\HubDistributor:
|
||||
arguments:
|
||||
$redis: "@App\\Service\\RedisClientProvider"
|
||||
$hub_jo_key: "%env(HUB_JO_KEY)%"
|
||||
|
||||
# hub filter logger
|
||||
App\Service\HubFilterLogger:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
|
|
|||
|
|
@ -2519,14 +2519,11 @@ class APIController extends Controller implements LoggedController
|
|||
// check if hub is null
|
||||
if ($hub == null)
|
||||
{
|
||||
// TODO: set this properly. This is test data
|
||||
// TODO: set this properly, since the other flags
|
||||
// are on default values
|
||||
$hub_criteria = new HubCriteria();
|
||||
$hub_criteria->setPoint($jo->getCoordinates())
|
||||
->setLimitResults(50)
|
||||
->setLimitDistance(100)
|
||||
->setInventoryCheck(false)
|
||||
->setJoType($jo->getServiceType())
|
||||
->setDateTime(new DateTime());
|
||||
->setJoType($jo->getServiceType());
|
||||
|
||||
// add battery to items
|
||||
$sku = $batt->getSAPCode();
|
||||
|
|
|
|||
29
src/Service/HubFilterLogger.php
Normal file
29
src/Service/HubFilterLogger.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Entity\Hub;
|
||||
use App\Entity\HubFilterLog;
|
||||
|
||||
class HubFilterLogger
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function logFilteredHub(Hub $hub, $filter_type)
|
||||
{
|
||||
$hub_filter_log = new HubFilterLog();
|
||||
|
||||
$hub_filter_log->setHub($hub)
|
||||
->setFilterTypeId($filter_type);
|
||||
|
||||
$this->em->persist($hub_filter_log);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ use App\Entity\Hub;
|
|||
|
||||
use App\Service\HubDistributor;
|
||||
use App\Service\InventoryManager;
|
||||
use App\Service\HubFilterLogger;
|
||||
|
||||
use App\Ramcar\HubCriteria;
|
||||
use App\Ramcar\ServiceType;
|
||||
|
|
@ -19,13 +20,15 @@ class HubSelector
|
|||
protected $em;
|
||||
protected $im;
|
||||
protected $hub_distributor;
|
||||
protected $hub_filter_logger;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, InventoryManager $im,
|
||||
HubDistributor $hub_distributor)
|
||||
HubDistributor $hub_distributor, HubFilterLogger $hub_filter_logger)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->im = $im;
|
||||
$this->hub_distributor = $hub_distributor;
|
||||
$this->hub_filter_logger = $hub_filter_logger;
|
||||
}
|
||||
|
||||
public function find(HubCriteria $criteria)
|
||||
|
|
@ -97,10 +100,12 @@ class HubSelector
|
|||
return $hubs;
|
||||
|
||||
$results = [];
|
||||
for ($i = 0; $i < $limit_result; $i++)
|
||||
for ($i = 0; $i < count($hubs); $i++)
|
||||
{
|
||||
if ($i < count($hubs))
|
||||
if ($i < $limit_result)
|
||||
$results[] = $hubs[$i];
|
||||
else
|
||||
$this->hub_filter_logger->logFilteredHub($hubs[$i]['hub'], 'max_results');
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
|
@ -129,6 +134,8 @@ class HubSelector
|
|||
'distance' => $hub_data['distance'],
|
||||
'duration' => $hub_data['duration'],
|
||||
];
|
||||
else
|
||||
$this->hub_filter_logger->logFilteredHub($hub, 'job_order_type');
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
|
@ -149,6 +156,8 @@ class HubSelector
|
|||
// go through each hub's opening times to check if hub is open
|
||||
// for the specified time
|
||||
// get hub opening and closing times
|
||||
// TODO: maybe in the future, might also have to check if hub
|
||||
// is open/available on date/day
|
||||
$hub = $hub_data['hub'];
|
||||
|
||||
$time_open = $hub->getTimeOpen()->format("H:i:s");
|
||||
|
|
@ -166,6 +175,8 @@ class HubSelector
|
|||
'duration' => $hub_data['duration'],
|
||||
];
|
||||
}
|
||||
else
|
||||
$this->hub_filter_logger->logFilteredHub($hub, 'date_and_time');
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
|
@ -196,7 +207,9 @@ class HubSelector
|
|||
'db_distance' => $hub_data['db_distance'],
|
||||
'distance' => $hub_data['distance'],
|
||||
'duration' => $hub_data['duration'],
|
||||
];
|
||||
];
|
||||
else
|
||||
$this->hub_filter_logger->logFilteredHub($hub, 'inventory');
|
||||
}
|
||||
if ($jo_type == ServiceType::BATTERY_REPLACEMENT_WARRANTY)
|
||||
{
|
||||
|
|
@ -209,6 +222,8 @@ class HubSelector
|
|||
'distance' => $hub_data['distance'],
|
||||
'duration' => $hub_data['duration'],
|
||||
];
|
||||
else
|
||||
$this->hub_filter_logger->logFilteredHub($hub, 'inventory');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -255,6 +270,10 @@ class HubSelector
|
|||
'duration' => 0,
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->hub_filter_logger->logFilteredHub($row[0], 'distance');
|
||||
}
|
||||
}
|
||||
|
||||
return $hubs_data;
|
||||
|
|
|
|||
Loading…
Reference in a new issue