From 372e7e4cd55ac0ec129aaecc7fa4dd221d6f1afc Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Mon, 2 Dec 2024 15:22:12 +0200 Subject: [PATCH] UHF-9937: Remove changed migration --- .../openshift/crons/migrate-job-listings.sh | 2 +- .../migrations/job_listings.yml | 1 - .../Plugin/Deriver/HelbitMigrationDeriver.php | 6 +---- .../Plugin/migrate/source/HelbitOpenJobs.php | 4 ---- .../src/Kernel/HelbitMigrationDeriverTest.php | 13 ----------- .../tests/src/Kernel/HelbitOpenJobsTest.php | 23 ------------------- 6 files changed, 2 insertions(+), 47 deletions(-) diff --git a/docker/openshift/crons/migrate-job-listings.sh b/docker/openshift/crons/migrate-job-listings.sh index 12f1b580..3b0a1627 100644 --- a/docker/openshift/crons/migrate-job-listings.sh +++ b/docker/openshift/crons/migrate-job-listings.sh @@ -1,7 +1,7 @@ #!/bin/bash migrations=( - "helfi_rekry_jobs:all" + "helfi_rekry_jobs" ) echo "Starting job listing:changed migrations: $(date)" diff --git a/public/modules/custom/helfi_rekry_content/migrations/job_listings.yml b/public/modules/custom/helfi_rekry_content/migrations/job_listings.yml index 7f12af52..39345e2b 100644 --- a/public/modules/custom/helfi_rekry_content/migrations/job_listings.yml +++ b/public/modules/custom/helfi_rekry_content/migrations/job_listings.yml @@ -5,7 +5,6 @@ dependencies: module: - helfi_rekry_content id: helfi_rekry_jobs -deriver: Drupal\helfi_rekry_content\Plugin\Deriver\HelbitMigrationDeriver migration_tags: - helfi_rekry_content - helfi_rekry_jobs diff --git a/public/modules/custom/helfi_rekry_content/src/Plugin/Deriver/HelbitMigrationDeriver.php b/public/modules/custom/helfi_rekry_content/src/Plugin/Deriver/HelbitMigrationDeriver.php index ab950950..41029dbb 100644 --- a/public/modules/custom/helfi_rekry_content/src/Plugin/Deriver/HelbitMigrationDeriver.php +++ b/public/modules/custom/helfi_rekry_content/src/Plugin/Deriver/HelbitMigrationDeriver.php @@ -36,7 +36,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) : */ public function getDerivativeDefinitions($base_plugin_definition): array { $langcodes = ['fi', 'sv', 'en']; - $derivatives = ['all', 'changed']; + $derivatives = ['all']; if ($base_plugin_definition['source']['plugin'] == 'helbit_open_jobs') { foreach ($derivatives as $key) { @@ -64,10 +64,6 @@ public function getDerivativeDefinitions($base_plugin_definition): array { * Modified plugin definition for derivative. */ private function getJobMigrationDerivativeValues(array $base_plugin_definition, string $key): array { - if (str_starts_with($key, 'changed')) { - $base_plugin_definition['source']['changed'] = TRUE; - } - return $base_plugin_definition; } diff --git a/public/modules/custom/helfi_rekry_content/src/Plugin/migrate/source/HelbitOpenJobs.php b/public/modules/custom/helfi_rekry_content/src/Plugin/migrate/source/HelbitOpenJobs.php index 838048a7..18e218ca 100644 --- a/public/modules/custom/helfi_rekry_content/src/Plugin/migrate/source/HelbitOpenJobs.php +++ b/public/modules/custom/helfi_rekry_content/src/Plugin/migrate/source/HelbitOpenJobs.php @@ -50,10 +50,6 @@ protected function initializeIterator(): \Iterator { $query = []; - if ($this->configuration['changed'] ?? FALSE) { - $query['timestamp'] = date('Y-m-d\TH:m:i', strtotime('-1 day')); - } - foreach ($langcodes as $langcode) { foreach ($this->helbit->getJobListings($langcode, $query) as $row) { $fields = $this->getFieldsFromRow($row) + [ diff --git a/public/modules/custom/helfi_rekry_content/tests/src/Kernel/HelbitMigrationDeriverTest.php b/public/modules/custom/helfi_rekry_content/tests/src/Kernel/HelbitMigrationDeriverTest.php index 8cd3a65a..4f209c27 100644 --- a/public/modules/custom/helfi_rekry_content/tests/src/Kernel/HelbitMigrationDeriverTest.php +++ b/public/modules/custom/helfi_rekry_content/tests/src/Kernel/HelbitMigrationDeriverTest.php @@ -21,19 +21,6 @@ class HelbitMigrationDeriverTest extends KernelTestBase { * Tests Helbit deriver. */ public function testHelbitDeriver(): void { - $deriver = new HelbitMigrationDeriver(new Settings(self::TEST_HELBIT_KEY)); - $result = $deriver->getDerivativeDefinitions([ - 'id' => 'helfi_rekry_jobs', - 'source' => [ - 'plugin' => 'helbit_open_jobs', - ], - ]); - - $this->assertArrayHasKey('all', $result); - $this->assertArrayHasKey('changed', $result); - $this->assertEmpty($result['all']['source']['changed'] ?? NULL); - $this->assertTrue($result['changed']['source']['changed']); - $deriver = new HelbitMigrationDeriver(new Settings(self::TEST_HELBIT_KEY)); $result = $deriver->getDerivativeDefinitions([ 'id' => 'helfi_rekry_task_areas', diff --git a/public/modules/custom/helfi_rekry_content/tests/src/Kernel/HelbitOpenJobsTest.php b/public/modules/custom/helfi_rekry_content/tests/src/Kernel/HelbitOpenJobsTest.php index 0e51f0de..355366ee 100644 --- a/public/modules/custom/helfi_rekry_content/tests/src/Kernel/HelbitOpenJobsTest.php +++ b/public/modules/custom/helfi_rekry_content/tests/src/Kernel/HelbitOpenJobsTest.php @@ -50,29 +50,6 @@ public function testException(): void { ->next(); } - /** - * Tests that changed timestamp is present in request when configured. - */ - public function testChangedTimestamp(): void { - $isValidTime = static fn (array $query) => preg_match('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/', $query['timestamp']); - - $helbit = $this->prophesize(HelbitClient::class); - $helbit - ->getJobListings(Argument::any(), Argument::that($isValidTime)) - ->shouldBeCalled(); - - $this - ->getSut($helbit->reveal(), [ - 'changed' => TRUE, - 'ids' => [ - 'id' => [ - 'type' => 'string', - ], - ], - ]) - ->next(); - } - /** * Tests iterator. */