|
@@ -26,6 +26,7 @@ use HttpException;
|
|
|
use libphonenumber\PhoneNumber;
|
|
use libphonenumber\PhoneNumber;
|
|
|
use libphonenumber\PhoneNumberFormat;
|
|
use libphonenumber\PhoneNumberFormat;
|
|
|
use libphonenumber\PhoneNumberUtil;
|
|
use libphonenumber\PhoneNumberUtil;
|
|
|
|
|
+use Monolog\Handler\RotatingFileHandler;
|
|
|
use Psr\Log\LoggerInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
|
|
|
|
|
|
@@ -33,7 +34,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|
|
* Push the data from the Opentalent DB into the Dolibarr DB, trough both applications
|
|
* Push the data from the Opentalent DB into the Dolibarr DB, trough both applications
|
|
|
* REST APIs.
|
|
* REST APIs.
|
|
|
*
|
|
*
|
|
|
- * ** /!\ This sync is and must stay one-sided: opentalent data => dolibarr db **
|
|
|
|
|
|
|
+ * ** /!\ This sync is and must remain one-sided: Opentalent DB => Dolibarr DB **
|
|
|
*/
|
|
*/
|
|
|
class DolibarrSyncService
|
|
class DolibarrSyncService
|
|
|
{
|
|
{
|
|
@@ -59,7 +60,7 @@ class DolibarrSyncService
|
|
|
* @throws Exception
|
|
* @throws Exception
|
|
|
*/
|
|
*/
|
|
|
public function scan(): array {
|
|
public function scan(): array {
|
|
|
- $this->logger->info("Dolibarr sync started");
|
|
|
|
|
|
|
+ $this->logger->info("-- Scan started --");
|
|
|
|
|
|
|
|
// Index the dolibarr clients by organization ids
|
|
// Index the dolibarr clients by organization ids
|
|
|
$dolibarrClientsIndex = $this->getDolibarrSocietiesIndex();
|
|
$dolibarrClientsIndex = $this->getDolibarrSocietiesIndex();
|
|
@@ -263,6 +264,7 @@ class DolibarrSyncService
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $this->logger->info('Scan ended');
|
|
|
return $operations;
|
|
return $operations;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -277,18 +279,20 @@ class DolibarrSyncService
|
|
|
*/
|
|
*/
|
|
|
public function execute(array $operations): array
|
|
public function execute(array $operations): array
|
|
|
{
|
|
{
|
|
|
- $this->logger->info('Execution started, ' . count($operations) . ' operations pending...');
|
|
|
|
|
|
|
+ $this->logger->info('-- Execution started --');
|
|
|
|
|
+ $this->logger->info(count($operations) . ' operations pending...');
|
|
|
$done = 0; $errors = 0; $unknown = 0;
|
|
$done = 0; $errors = 0; $unknown = 0;
|
|
|
|
|
|
|
|
foreach ($operations as $operation) {
|
|
foreach ($operations as $operation) {
|
|
|
if ($operation->getStatus() !== DolibarrSyncOperation::STATUS_READY) {
|
|
if ($operation->getStatus() !== DolibarrSyncOperation::STATUS_READY) {
|
|
|
// operation has already been treated
|
|
// operation has already been treated
|
|
|
|
|
+ $this->logger->warning('Tried to execute an operation that was not marked as ready : ' . $operation);
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
$operation->execute();
|
|
$operation->execute();
|
|
|
|
|
|
|
|
if ($operation->getStatus() === DolibarrSyncOperation::STATUS_ERROR) {
|
|
if ($operation->getStatus() === DolibarrSyncOperation::STATUS_ERROR) {
|
|
|
- $this->logger->error('Error while executing : ' . $operation);
|
|
|
|
|
|
|
+ $this->logger->error('Error while executing operation : ' . $operation);
|
|
|
$this->logger->error($operation->getErrorMessage());
|
|
$this->logger->error($operation->getErrorMessage());
|
|
|
$errors++;
|
|
$errors++;
|
|
|
} elseif ($operation->getStatus() === DolibarrSyncOperation::STATUS_DONE) {
|
|
} elseif ($operation->getStatus() === DolibarrSyncOperation::STATUS_DONE) {
|