Skip to content

Commit

Permalink
UHF-9937: Remove changed migration
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrsky committed Dec 2, 2024
1 parent 88f3096 commit 6bbd191
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 71 deletions.
2 changes: 1 addition & 1 deletion docker/openshift/crons/migrate-job-listings.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

migrations=(
"helfi_rekry_jobs:all"
"helfi_rekry_jobs"
)

echo "Starting job listing:changed migrations: $(date)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,41 +36,14 @@ public static function create(ContainerInterface $container, $base_plugin_id) :
*/
public function getDerivativeDefinitions($base_plugin_definition): array {
$langcodes = ['fi', 'sv', 'en'];
$derivatives = ['all', 'changed'];

if ($base_plugin_definition['source']['plugin'] == 'helbit_open_jobs') {
foreach ($derivatives as $key) {
$this->derivatives[$key] = $this->getJobMigrationDerivativeValues($base_plugin_definition, $key);
}
}
else {
foreach ($langcodes as $langcode) {
$this->derivatives[$langcode] = $this->getDerivativeValues($base_plugin_definition, $langcode);
}
foreach ($langcodes as $langcode) {
$this->derivatives[$langcode] = $this->getDerivativeValues($base_plugin_definition, $langcode);
}

return $this->derivatives;
}

/**
* Creates a derivative definition for job migration.
*
* @param array $base_plugin_definition
* Base migration definitions.
* @param string $key
* Key for derivative.
*
* @return 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;
}

/**
* Creates a derivative definition for each available language.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) + [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 6bbd191

Please sign in to comment.