Skip to content

Commit

Permalink
VACMS-15559 Programatically shut off queue checks and processing.
Browse files Browse the repository at this point in the history
  • Loading branch information
swirtSJW committed Jan 31, 2024
1 parent 5ae1cff commit 9920416
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docroot/modules/custom/va_gov_vamc/va_gov_vamc.deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ function va_gov_vamc_deploy_build_va_police_9001(&$sandbox) {
/**
* Migrate some facility service data to service location paragraphs.
*/
function va_gov_vamc_deploy_migrate_service_data_to_service_location_9002(&$sandbox) {
function va_gov_vamc_deploy_migrate_service_data_to_service_location_9003(&$sandbox) {

$source_bundle = 'health_care_local_health_service';
script_library_sandbox_init($sandbox, 'get_nids_of_type', [$source_bundle, FALSE]);
script_library_toggle_post_api_queueing(TRUE);
new ServiceLocationMigration($sandbox);
$new_service_locations = $sandbox['service_locations_created_count'] ?? 0;
$updated_service_locations = $sandbox['service_locations_updated_count'] ?? 0;
$forward_revisions = $sandbox['forward_revisions_count'] ?? 0;
script_library_toggle_post_api_queueing(FALSE);

return script_library_sandbox_complete($sandbox, "migrated @total {$source_bundle} nodes into {$new_service_locations} new service_location paragraphs, and {$updated_service_locations} updated. Also updated {$forward_revisions} forward revisions.");
}
20 changes: 20 additions & 0 deletions scripts/content/script-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,26 @@ function script_libary_map_to_value(string|null $lookup, array $map, bool $stric
}
}

/**
* Turns on or off settings related to the post_api.
*
* @param bool $state
* TRUE to toggle the settings on, FALSE to toggle them off.
*/
function script_library_toggle_post_api_queueing(bool $state): void {
$state = ($state) ? 1 : 0;
$config_post_api = \Drupal::configFactory()->getEditable('post_api.settings');

$config_post_api->set('pause_cron_processing', $state)
// CONSIDER: The only time we would want to fully disable queueing is during
// a deploy when editors can not save anything.
// ->set('disable_queueing', $state) .
->save(FALSE);
$config_va_gov_post_api = \Drupal::configFactory()->getEditable('va_gov_post_api.settings');
$config_va_gov_post_api->set('bypass_data_check', $state)
->save(FALSE);
}

/**
* Callback function to concat node ids with string.
*
Expand Down

0 comments on commit 9920416

Please sign in to comment.