Skip to content

Commit

Permalink
Debug import
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane MEAUDRE committed Mar 25, 2024
1 parent a9df1f2 commit cfadd1a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Repository\ElasticsearchRepository;

use App\Command\ImportDataCommand;
use App\Services\Elasticsearch;
use App\Services\Notification;
use Elasticsearch\Client;
use App\Command\ImportDeltaDataCommand;

abstract class AbstractRepository
{
Expand Down Expand Up @@ -86,15 +86,15 @@ public function insertDocument(array $document): void
];

switch($document['mode']) {
case ImportDataCommand::MODE_CREATE_DOCUMENT: $this->client->create($param);
case ImportDeltaDataCommand::MODE_CREATE_DOCUMENT: $this->client->create($param);
break;
case ImportDataCommand::MODE_UPDATE_DOCUMENT: $this->client->update($param);
case ImportDeltaDataCommand::MODE_UPDATE_DOCUMENT: $this->client->update($param);
break;
};

$message = match($document['mode']) {
ImportDataCommand::MODE_CREATE_DOCUMENT => sprintf('New object have been added: "%s"', $document['data']['id']),
ImportDataCommand::MODE_UPDATE_DOCUMENT => sprintf('"%s" have been updated',$document['data']['id'])
ImportDeltaDataCommand::MODE_CREATE_DOCUMENT => sprintf('New object have been added: "%s"', $document['data']['id']),
ImportDeltaDataCommand::MODE_UPDATE_DOCUMENT => sprintf('"%s" have been updated',$document['data']['id'])
};

$notification = [
Expand Down
5 changes: 2 additions & 3 deletions api/src/State/DsoStateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use App\Repository\ElasticsearchRepository\DsoRepository;
use App\Services\Factory\DsoFactory;
use Psr\Cache\InvalidArgumentException;
use Symfony\Component\HttpFoundation\InputBag;

readonly class DsoStateProvider implements ProviderInterface
{
Expand Down Expand Up @@ -70,9 +69,9 @@ public function provide(
} else {
['id' => $dsoId] = $uriVariables;
// Retrieve the state from somewhere
$document = $this->dsoRepository->findById(ImportDataCommand::md5ForId($dsoId));
$document = $this->dsoRepository->findById(ImportDeltaDataCommand::md5ForId($dsoId));
if ($document['const_id']) {
$document['constellation'] = $this->constellationRepository->findById(ImportDataCommand::md5ForId($document['const_id']));
$document['constellation'] = $this->constellationRepository->findById(ImportDeltaDataCommand::md5ForId($document['const_id']));
}

$dsoRepresentation = fn() => yield from $this->dsoFactory->buildDto($document);
Expand Down

0 comments on commit cfadd1a

Please sign in to comment.