From 211fbfcf5d2cd58b8e4160895c5d8085c82edbc1 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 20 Nov 2024 14:06:34 +0100 Subject: [PATCH] Auto stash before merge of "feature/GW-1760/logging-postgresql" and "origin/development" --- api/src/Controller/LogController.php | 2 ++ api/src/Service/SynchronizationService.php | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/api/src/Controller/LogController.php b/api/src/Controller/LogController.php index 0d5adeb67..2757b07a3 100644 --- a/api/src/Controller/LogController.php +++ b/api/src/Controller/LogController.php @@ -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; @@ -41,6 +42,7 @@ public function __construct( private readonly CacheService $cacheService, private readonly RequestService $requestService, private readonly ParameterBagInterface $parameterBag, + private readonly EntityManagerInterface $entityManager, ) { diff --git a/api/src/Service/SynchronizationService.php b/api/src/Service/SynchronizationService.php index 5b86359f7..1f247fb4b 100644 --- a/api/src/Service/SynchronizationService.php +++ b/api/src/Service/SynchronizationService.php @@ -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: ', ]]); @@ -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? @@ -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);