Skip to content

Commit

Permalink
Merge pull request #832 from UN-OCHA/berliner/HPC-9306
Browse files Browse the repository at this point in the history
HPC-9306: Only update articles that need an update
  • Loading branch information
berliner authored Nov 25, 2023
2 parents b8f895e + 23530ac commit 3c7bcc3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public function onMigratePostRowSave(MigratePostRowSaveEvent $event) {
if (!in_array($event->getMigration()->id(), $migration_ids)) {
return;
}
if (!$event->getRow()->needsUpdate()) {
return;
}
$ids = $event->getDestinationIdValues();
$entities = $this->entityTypeManager->getStorage('node')->loadMultiple($ids);
foreach ($entities as $entity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ public function searchArticlesByTitle($title) {
* {@inheritdoc}
*/
public function query($payload) {
$body = '{"query": "query ' . str_replace("\n", " ", addslashes(trim($payload))) . '"}';
$query = 'query ' . str_replace("\n", " ", addslashes(trim($payload)));
$body = '{"query": "' . $query . '"}';

$headers = [
'Content-type' => 'application/json',
'Apollo-Require-Preflight' => 'true',
Expand All @@ -225,7 +227,6 @@ public function query($payload) {
'body' => $body,
'headers' => $headers,
'cookies' => $jar,
'timeout' => 60000,
];

// See if we have a cached version already for this request.
Expand All @@ -237,6 +238,7 @@ public function query($payload) {

// Otherwise send the query.
$response = new RemoteResponse();
$result = NULL;
try {
$result = $this->httpClient->post($this->getRemoteEndpointUrl(), $post_args);
}
Expand All @@ -248,6 +250,9 @@ public function query($payload) {
$response->setCode($e->getCode());
return $response;
}
catch (Exception $e) {
// Just fail silently.
}

if (!$result || $result->getStatusCode() !== 200) {
$response->setCode($result ? $result->getStatusCode() : 500);
Expand Down

0 comments on commit 3c7bcc3

Please sign in to comment.