Skip to content

Commit

Permalink
Auto stash before merge of "feature/GW-1760/logging-postgresql" and "…
Browse files Browse the repository at this point in the history
…origin/development"
  • Loading branch information
rjzondervan committed Nov 20, 2024
1 parent 7493bf9 commit 211fbfc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions api/src/Controller/LogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use CommonGateway\CoreBundle\Service\CacheService;
use CommonGateway\CoreBundle\Service\RequestService;
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use MongoDB\BSON\ObjectId;
use MongoDB\BSON\UTCDateTime;
Expand Down Expand Up @@ -41,6 +42,7 @@ public function __construct(
private readonly CacheService $cacheService,
private readonly RequestService $requestService,
private readonly ParameterBagInterface $parameterBag,
private readonly EntityManagerInterface $entityManager,

)
{
Expand Down
14 changes: 10 additions & 4 deletions api/src/Service/SynchronizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,9 @@ public function getSingleFromSource(Synchronization $synchronization): ?array
]
);
} catch (Exception|GuzzleException $exception) {
var_dump($exception->getMessage());


$this->ioCatchException($exception, ['line', 'file', 'message' => [
'preMessage' => 'Error while doing getSingleFromSource: ',
]]);
Expand Down Expand Up @@ -1039,6 +1042,12 @@ public function synchronize(Synchronization $synchronization, array $sourceObjec
$now = new DateTime();
$synchronization->setLastChecked($now);

$sha = hash('sha256', json_encode($sourceObject));

if($synchronization->getSha() === $sha) {
return $synchronization;
}

// Todo: we never check if we actually have to sync anything... see handleSync functie for an example:
// if (!$synchronization->getLastSynced() || ($synchronization->getLastSynced() < $synchronization->getSourceLastChanged() && $synchronization->getSourceLastChanged() >= $synchronization->getObject()->getDateModified())) {
// Todo: @ruben i heard from @robert we wanted to do this check somewhere else?
Expand All @@ -1064,10 +1073,7 @@ public function synchronize(Synchronization $synchronization, array $sourceObjec
}
$synchronization->getObject()->hydrate($sourceObject, $unsafe);

if ($this->sha !== null) {
$synchronization->setSha($this->sha);
$this->sha = null;
}
$synchronization->setSha($sha);

$this->entityManager->persist($synchronization->getObject());
$this->entityManager->persist($synchronization);
Expand Down

0 comments on commit 211fbfc

Please sign in to comment.